saving work

This commit is contained in:
Tanushree Tunstall 2020-11-27 18:21:35 +00:00
parent a43f323ed8
commit 47a03c2639

View file

@ -50,16 +50,16 @@ if( length(sam_cols_clean) == length(sam_cols) - length(sam_cols_to_omit) ){
, "Got:", length(sam_cols_clean) ) , "Got:", length(sam_cols_clean) )
} }
sam_cols_to_extract = c(meta_data_cols, sam_cols_clean) sam_cols_to_extract = c(meta_clinical_cols, sam_cols_clean)
cat("Extracting SAM cols + metadata_cols") cat("Extracting SAM cols + metadata_cols")
if ( length(sam_cols_to_extract) == length(meta_data_cols) + length(sam_cols_clean) ){ if ( length(sam_cols_to_extract) == length(meta_clinical_cols) + length(sam_cols_clean) ){
cat("Extracing", length(sam_cols_to_extract), "columns for sam") cat("Extracing", length(sam_cols_to_extract), "columns for sam")
sam_df = my_data[, sam_cols_to_extract] sam_df = my_data[, sam_cols_to_extract]
}else{ }else{
cat("FAIL: length mismatch" cat("FAIL: length mismatch"
, "Expeceted to extract:", length(meta_data_cols) + length(sam_cols_clean), "columns" , "Expeceted to extract:", length(meta_clinical_cols) + length(sam_cols_clean), "columns"
, "Got:", length(sam_cols_to_extract)) , "Got:", length(sam_cols_to_extract))
} }
@ -90,16 +90,16 @@ if( length(serum_cols_clean) == length(serum_cols) - length(serum_cols_to_omit)
, "Got:", length(serum_cols_clean) ) , "Got:", length(serum_cols_clean) )
} }
serum_cols_to_extract = c(meta_data_cols, serum_cols_clean) serum_cols_to_extract = c(meta_clinical_cols, serum_cols_clean)
cat("Extracting SERUM cols + metadata_cols") cat("Extracting SERUM cols + metadata_cols")
if ( length(serum_cols_to_extract) == length(meta_data_cols) + length(serum_cols_clean) ){ if ( length(serum_cols_to_extract) == length(meta_clinical_cols) + length(serum_cols_clean) ){
cat("Extracing", length(serum_cols_to_extract), "columns for serum") cat("Extracing", length(serum_cols_to_extract), "columns for serum")
serum_df = my_data[, serum_cols_to_extract] serum_df = my_data[, serum_cols_to_extract]
}else{ }else{
cat("FAIL: length mismatch" cat("FAIL: length mismatch"
, "Expeceted to extract:", length(meta_data_cols) + length(serum_cols_clean), "columns" , "Expeceted to extract:", length(meta_clinical_cols) + length(serum_cols_clean), "columns"
, "Got:", length(serum_cols_to_extract)) , "Got:", length(serum_cols_to_extract))
} }
@ -130,16 +130,16 @@ if( length(npa_cols_clean) == length(npa_cols) - length(npa_cols_to_omit) ){
, "Got:", length(npa_cols_clean) ) , "Got:", length(npa_cols_clean) )
} }
npa_cols_to_extract = c(meta_data_cols, npa_cols_clean) npa_cols_to_extract = c(meta_clinical_cols, npa_cols_clean)
cat("Extracting NPA cols + metadata_cols") cat("Extracting NPA cols + metadata_cols")
if ( length(npa_cols_to_extract) == length(meta_data_cols) + length(npa_cols_clean) ){ if ( length(npa_cols_to_extract) == length(meta_clinical_cols) + length(npa_cols_clean) ){
cat("Extracing", length(npa_cols_to_extract), "columns for npa") cat("Extracing", length(npa_cols_to_extract), "columns for npa")
npa_df = my_data[, npa_cols_to_extract] npa_df = my_data[, npa_cols_to_extract]
}else{ }else{
cat("FAIL: length mismatch" cat("FAIL: length mismatch"
, "Expeceted to extract:", length(meta_data_cols) + length(npa_cols_clean), "columns" , "Expeceted to extract:", length(meta_clinical_cols) + length(npa_cols_clean), "columns"
, "Got:", length(npa_cols_to_extract)) , "Got:", length(npa_cols_to_extract))
} }
@ -184,11 +184,11 @@ cols_to_omit = c("adult"
#, "weight_unit", "visual_est_bmi", "bmi_rating" #, "weight_unit", "visual_est_bmi", "bmi_rating"
) )
pivot_cols = meta_data_cols pivot_cols = meta_clinical_cols
# subselect pivot_cols # subselect pivot_cols
pivot_cols = meta_data_cols[!meta_data_cols%in%cols_to_omit];pivot_cols pivot_cols = meta_clinical_cols[!meta_clinical_cols%in%cols_to_omit];pivot_cols
ncols_omitted = table(meta_data_cols%in%cols_to_omit)[[2]] ncols_omitted = table(meta_clinical_cols%in%cols_to_omit)[[2]]
ncols_omitted ncols_omitted
#============== #==============
@ -203,16 +203,16 @@ sam_df_adults = sam_df
wf_cols = colnames(sam_df_adults)[!colnames(sam_df_adults)%in%cols_to_omit] wf_cols = colnames(sam_df_adults)[!colnames(sam_df_adults)%in%cols_to_omit]
sam_wf = sam_df_adults[wf_cols] sam_wf = sam_df_adults[wf_cols]
pivot_cols = meta_data_cols pivot_cols = meta_clinical_cols
# subselect pivot_cols # subselect pivot_cols
pivot_cols = meta_data_cols[!meta_data_cols%in%cols_to_omit];pivot_cols pivot_cols = meta_clinical_cols[!meta_clinical_cols%in%cols_to_omit];pivot_cols
if (length(pivot_cols) == length(meta_data_cols) - ncols_omitted){ if (length(pivot_cols) == length(meta_clinical_cols) - ncols_omitted){
cat("PASS: pivot cols successfully extracted") cat("PASS: pivot cols successfully extracted")
}else{ }else{
cat("FAIL: length mismatch! pivot cols could not be extracted" cat("FAIL: length mismatch! pivot cols could not be extracted"
, "\nExpected length:", length(meta_data_cols) - ncols_omitted , "\nExpected length:", length(meta_clinical_cols) - ncols_omitted
, "\nGot:",length(pivot_cols) ) , "\nGot:",length(pivot_cols) )
quit() quit()
} }
@ -256,14 +256,14 @@ serum_df_adults = serum_df
wf_cols = colnames(serum_df_adults)[!colnames(serum_df_adults)%in%cols_to_omit] wf_cols = colnames(serum_df_adults)[!colnames(serum_df_adults)%in%cols_to_omit]
serum_wf = serum_df_adults[wf_cols] serum_wf = serum_df_adults[wf_cols]
pivot_cols = meta_data_cols pivot_cols = meta_clinical_cols
pivot_cols = meta_data_cols[!meta_data_cols%in%cols_to_omit];pivot_cols pivot_cols = meta_clinical_cols[!meta_clinical_cols%in%cols_to_omit];pivot_cols
if (length(pivot_cols) == length(meta_data_cols) - ncols_omitted){ if (length(pivot_cols) == length(meta_clinical_cols) - ncols_omitted){
cat("PASS: pivot cols successfully extracted") cat("PASS: pivot cols successfully extracted")
}else{ }else{
cat("FAIL: length mismatch! pivot cols could not be extracted" cat("FAIL: length mismatch! pivot cols could not be extracted"
, "\nExpected length:", length(meta_data_cols) - ncols_omitted , "\nExpected length:", length(meta_clinical_cols) - ncols_omitted
, "\nGot:",length(pivot_cols) ) , "\nGot:",length(pivot_cols) )
quit() quit()
} }
@ -303,14 +303,14 @@ npa_df_adults = npa_df
wf_cols = colnames(npa_df_adults)[!colnames(npa_df_adults)%in%cols_to_omit] wf_cols = colnames(npa_df_adults)[!colnames(npa_df_adults)%in%cols_to_omit]
npa_wf = npa_df_adults[wf_cols] npa_wf = npa_df_adults[wf_cols]
pivot_cols = meta_data_cols pivot_cols = meta_clinical_cols
pivot_cols = meta_data_cols[!meta_data_cols%in%cols_to_omit];pivot_cols pivot_cols = meta_clinical_cols[!meta_clinical_cols%in%cols_to_omit];pivot_cols
if (length(pivot_cols) == length(meta_data_cols) - ncols_omitted){ if (length(pivot_cols) == length(meta_clinical_cols) - ncols_omitted){
cat("PASS: pivot cols successfully extracted") cat("PASS: pivot cols successfully extracted")
}else{ }else{
cat("FAIL: length mismatch! pivot cols could not be extracted" cat("FAIL: length mismatch! pivot cols could not be extracted"
, "\nExpected length:", length(meta_data_cols) - ncols_omitted , "\nExpected length:", length(meta_clinical_cols) - ncols_omitted
, "\nGot:",length(pivot_cols) ) , "\nGot:",length(pivot_cols) )
quit() quit()
} }