@@ -7,14 +7,25 @@ library(dplyr)
77
88# #adding a command line argument
99args = commandArgs(trailingOnly = TRUE )
10- if (length(args )!= 2 ){
11- stop(" Need a sample file and synapse token as argument. Rscript 00_sample_gen.R [samplefile] [synapse token]" )
10+ if (length(args ) > 1 ){
11+ stop(" Up to one argument is allowed. This is the filepath to the previously run samples file." )
12+ }
13+
1214
15+ if (length(args ) == 0 || is.na(args [1 ]) || args [1 ] == " " || ! file.exists(args [1 ])) {
16+ orig_samples <- " "
17+ } else {
18+ orig_samples <- fread(args [1 ])
1319}
1420
15- orig_samples <- fread(args [1 ])
1621
17- synapser :: synLogin(authToken = args [2 ])
22+ # Check if Synapse token is available from the environment
23+ synapse_token <- Sys.getenv(" SYNAPSE_AUTH_TOKEN" )
24+ if (synapse_token == " " ) {
25+ stop(" Error: SYNAPSE_AUTH_TOKEN environment variable is not set." )
26+ }
27+
28+ synapser :: synLogin(authToken = synapse_token )
1829manifest <- synapser :: synTableQuery(" select * from syn53503360" )$ asDataFrame()| >
1930 as.data.frame()
2031
@@ -32,23 +43,18 @@ manifest<-synapser::synTableQuery("select * from syn53503360")$asDataFrame()|>
3243# #first create samples for the original tumors
3344tumorTable <- manifest | >
3445 dplyr :: select(common_name = ' Sample' )| >
35- dplyr :: mutate(other_id_source = ' NF Data Portal' ,other_names = ' ' ,cancer_type = " Malignant peripheral nerve sheath tumor" ,species = ' Human' ,model_type = ' tumor' )| >
46+ dplyr :: mutate(other_id_source = ' NF Data Portal' ,other_names = ' ' ,cancer_type = " Malignant peripheral nerve sheath tumor" ,species = ' Homo sapiens ( Human) ' ,model_type = ' tumor' )| >
3647 tidyr :: unite(col = ' other_id' ,c(' common_name' ,' model_type' ),sep = ' ' ,remove = FALSE )
3748
3849# #then create samples for the PDX
3950sampTable <- manifest | >
4051 dplyr :: select(common_name = ' Sample' ,MicroTissueDrugFolder )| >
41- dplyr :: mutate(other_id_source = ' NF Data Portal' ,other_names = ' ' ,cancer_type = " Malignant peripheral nerve sheath tumor" ,species = ' Human' ,model_type = ' patient derived xenograft' )| >
52+ dplyr :: mutate(other_id_source = ' NF Data Portal' ,other_names = ' ' ,cancer_type = " Malignant peripheral nerve sheath tumor" ,species = ' Homo sapiens ( Human) ' ,model_type = ' patient derived xenograft' )| >
4253 tidyr :: unite(col = ' other_id' ,c(' common_name' ,' model_type' ),sep = ' ' ,remove = FALSE )
4354
4455
45- pdxmt <- manifest | >
46- dplyr :: select(common_name = ' Sample' ,MicroTissueDrugFolder )| >
47- dplyr :: mutate(other_id_source = ' NF Data Portal' ,other_names = ' ' ,cancer_type = " Malignant peripheral nerve sheath tumor" ,species = ' Human' ,model_type = ' organoid' )| >
48- tidyr :: unite(col = ' other_id' ,c(' common_name' ,' model_type' ),sep = ' ' ,remove = FALSE )
49-
5056# #third, generate a sample for the MTs if they were generated
51- # pdxmt<-subset(sampTable,!is.na(MicroTissueDrugFolder))
57+ pdxmt <- subset(sampTable ,! is.na(MicroTissueDrugFolder ))
5258pdxmt $ model_type = rep(' organoid' ,nrow(pdxmt ))
5359print(pdxmt )
5460
@@ -58,7 +64,15 @@ main<-rbind(sampTable,pdxmt)|>
5864
5965# main <- fread("mpnst/NF_MPNST_samples.csv")
6066# previous_aml <- fread(args[1])#"beatAML/beataml_samples.csv")
61- max_id <- max(orig_samples $ improve_sample_id )
67+
68+ # If there is no previous samples file - start at 1, else, continue where the previous one left off.
69+ if (identical(orig_samples , " " )) {
70+ max_id <- 1
71+ } else {
72+ max_id <- max(orig_samples $ improve_sample_id , na.rm = TRUE )
73+ }
74+
75+
6276main $ improve_sample_id <- seq(from = max_id + 1 , length.out = nrow(main ))
6377
6478# synapse_main <- fread("mpnst/synapse_NF-MPNST_samples.csv")
0 commit comments