You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed an issue when trying to wrap the cBioPortalData() function within another function or the mapply() function. It seems that when multiple arguments to cBioPortalData() are being passed in by temporary variables, the function fails to recognize the second variable, throwing the error, Error in FUN(X[[i]], ...): object 'y' not found.
# Load required packages
suppressPackageStartupMessages({
library(cBioPortalData)
library(dplyr)
})
# Set up cBioPortal APIcbio_api<- cBioPortal()
# Create named list of sample IDs according to study IDsample_list<-list(coadread_mskcc= c("EV-001-M", "EV-023-M", "EV-049-P",
"EV-012-P", "EV-027-M"),
mel_mskimpact_2020= c("P-0040090-T01-IM6",
"P-0004349-T01-IM5",
"P-0015881-T03-IM6",
"P-0005118-T01-IM5",
"P-0010005-T01-IM5"),
uvm_tcga= c("TCGA-V4-A9F7-01", "TCGA-WC-A881-01",
"TCGA-VD-A8KJ-01", "TCGA-V4-A9EX-01",
"TCGA-VD-A8KL-01"))
# Select 1st study for individual teststudy_a<- names(sample_list)[1]
study_a_samples<-sample_list[[1]]
# Basic application of cBioPortalData(), no issuesstudy_a_data<- cBioPortalData(api=cbio_api,
by="hugoGeneSymbol",
studyId=study_a,
sampleIds=study_a_samples,
genePanelId="IMPACT341")
#> harmonizing input:#> removing 64 colData rownames not in sampleMap 'primary'
# Create simple wrapper function for cBioPortalData()wrap_cBPD<-function(x, y) {
results<- cBioPortalData(api=cbio_api,
by="hugoGeneSymbol",
studyId=x,
sampleIds=y,
genePanelId="IMPACT341")
return(results)
}
# Test wrapper function with same data, throws error:test_data<- wrap_cBPD(study_a, study_a_samples)
#> Error in FUN(X[[i]], ...): object 'y' not found
# Test cBioPortalData() within for loop, no issuesresults_list<-list()
for (studyin names(sample_list)) {
study_samples<-sample_list[[study]]
results<- cBioPortalData(api=cbio_api,
by="hugoGeneSymbol",
studyId=study,
sampleIds=study_samples,
genePanelId="IMPACT341")
results_list[[study]] <-results
}
#> harmonizing input:#> removing 64 colData rownames not in sampleMap 'primary'#> harmonizing input:#> removing 691 colData rownames not in sampleMap 'primary'#> harmonizing input:#> removing 75 colData rownames not in sampleMap 'primary'
# Test cBioPortalData() within mapply(), throws error:mapply_test<- mapply(function(x, y) {
cBioPortalData(api=cbio_api,
by="hugoGeneSymbol",
studyId=x,
sampleIds=y,
genePanelId="IMPACT341")
}, names(sample_list), sample_list, SIMPLIFY=FALSE)
#> Error in FUN(X[[i]], ...): object 'y' not found
I noticed an issue when trying to wrap the
cBioPortalData()
function within another function or themapply()
function. It seems that when multiple arguments tocBioPortalData()
are being passed in by temporary variables, the function fails to recognize the second variable, throwing the error,Error in FUN(X[[i]], ...): object 'y' not found
.Created on 2024-08-29 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: