Skip to content

Commit

Permalink
updated template python
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas HOMBERG committed Nov 7, 2024
1 parent 3a090ae commit f212c8b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion phase-0-smoothie/bundle/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ A conda evnironnement is provided follow this steps to install and activate it:

To run the docker interactively you can run either R with :
- `sudo docker run -it -v .:/hadaca3 -w /hadaca3 hombergn/hadaca3_pyr R` and then `source("submission_script.R")` for the R version
- `sudo docker run -it -v .:/hadaca3 -w /hadaca3 hombergn/hadaca3_pyr python` and then `import submission_script` for the python version
- `sudo docker run -it -v .:/hadaca3 -w /hadaca3 hombergn/hadaca3_pyr python` and then `import submission_script` for the python version.


Beware that Mac users with M1 processors might encounter problems.

Expand Down
32 changes: 21 additions & 11 deletions templates/template_starter_kit/template_submission_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,37 @@

r_code_get_colnames = '''
get_colnames <- function(ref_names="reference_fruits.rds") {
reference_data = readRDS(ref_names)
return (colnames(reference_data))
ref_names = readRDS(ref_names)
return (colnames(ref_names))
}
'''
rpy2.robjects.r(r_code_get_colnames)
get_colnames = rpy2.robjects.r['get_colnames']

r_code_get_rownames = '''
get_rownames <- function(ref_names="reference_fruits.rds") {
ref_names = readRDS(ref_names)
return (rownames(ref_names))
}
'''
rpy2.robjects.r(r_code_get_rownames)
get_rownames = rpy2.robjects.r['get_rownames']

mixes_data = readRDS(os.path.join( "mixes_smoothies_fruits.rds"))
reference_data = readRDS(os.path.join( "reference_fruits.rds"))


pred_prop = program(
mix=mixes_data, ref=reference_data
)
file = "mixes_smoothies_fruits.rds"
mixes_data = pandas.DataFrame(mixes_data, index=get_rownames(file),columns=get_colnames(file))
file = "reference_fruits.rds"
reference_data = pandas.DataFrame(reference_data, index=get_rownames(file),columns=get_colnames(file))

get_colnames = rpy2.robjects.r['get_colnames']
colnames_result = get_colnames("reference_fruits.rds")
pred_prop_df = pandas.DataFrame(pred_prop, index=colnames_result)



pred_prop_df = program(mixes_data, reference_data )


##############################################################
### Check the prediction /!\ DO NOT CHANGE THIS PART ###
##############################################################
Expand Down Expand Up @@ -85,10 +96,9 @@ def validate_pred(pred, nb_samples=None, nb_cells=None, col_names=None):
print("Warning:")
print(error_informations)

# validate_pred <- function(pred, nb_samples = ncol(mixes_data) , nb_cells= ncol(reference_data),col_names = colnames(reference_data) )



validate_pred(pred_prop_df, nb_samples=mixes_data.shape[1] , nb_cells=reference_data.shape[1], col_names=colnames_result)
validate_pred(pred_prop_df, nb_samples=mixes_data.shape[1] , nb_cells=reference_data.shape[1], col_names=reference_data.columns)



Expand Down

0 comments on commit f212c8b

Please sign in to comment.