karissawhiting / cbioportalR

R package to wrap cBioPortal's API to pull data from public or private cBioPortal databases
https://www.karissawhiting.com/cbioportalR/
Other
19 stars 8 forks source link

How to get mRNA expression profiles #71

Open ypradat opened 8 months ago

ypradat commented 8 months ago

Dear @karissawhiting ,

I am opening another issue as I have been unable to load mRNA expression profiles from cbioportal. I tried the following.

set_cbioportal_db("public")

mycancerstudy <- "blca_tcga_pan_can_atlas_2018"

# get patient and sample lists for the study
mypatientlist <- available_patients(mycancerstudy)$patientId
mysamplelist <- available_samples(mycancerstudy)$sampleId

# check available molecular profiles and select the molecular profile for mRNA withouth Zscore transfo
geneticprofiles <- available_profiles(study_id=mycancerstudy) %>% pull(molecularProfileId)
geneticprofiles <- geneticprofiles[grepl("mrna", geneticprofiles)]
geneticprofiles <- geneticprofiles[!grepl("Zscores", geneticprofiles)]

# select the one i want
geneticprofile <- "tblca_tcga_pan_can_atlas_2018_rna_seq_v2_mrna"

# TRY 1: does not work
sample_study_pairs <- data.frame(sample_id=mysamplelist)
sample_study_pairs$study_id <- mycancerstudy
sample_study_pairs$molecular_profile_id <- geneticprofile
df_data <- get_genetics_by_sample(sample_study_pairs=sample_study_pairs, add_hugo=T)

# TRY 2: does not work either
body_api <- list(entrezGeneIds = EntrezGenes,
                             sampleIds = mysamplelist) %>%
                        purrr::discard(is.null)

body_url <- paste0("molecular-profiles/", geneticprofile, "/mrna-percentile/fetch?")
res <- cbp_api(url_path=body_url,
               method="post",
               body=body_api,
               base_url="www.cbioportal.org")
result <- purrr::map_dfr(res$content, ~purrr::list_flatten(.x))

I check on the API documentation here https://www.cbioportal.org/api/swagger-ui/index.html#/mRNA%20Percentile and was very surprised to see that the example request for mrna, i.e https://www.cbioportal.org/api/molecular-profiles/acc_tcga_rna_seq_v2_mrna/mrna-percentile/fetch?sampleId=TCGA-OR-A5J2-01, returns nothing in the body.

Can you advise on the procedure to retrieve mRNA expression profiles?

My settings are as in #70 .

Best regards, Yoann Pradat

karissawhiting commented 8 months ago

Hi @ypradat ! We don't support that endpoint yet (I believe it is a recent addition to endpoints in the cbioportal API). Currently we only support maf mutation files, copy number alterations and fusions.

I will keep this issue open and add this as a requested feature.

When I run the example on the docs you sent, I also get blank response, so may be worth reaching out to the cbioportal team regarding this specific data.

Thanks for your comments and suggestions!

ypradat commented 8 months ago

Ok I see, that would be great thanks!

The thing is I am very puzzled by the fact that a previous R api client named cgdsr (https://github.com/cBioPortal/cgdsr) was working just fine before they decided to change the API and deprecate this client.

Now I am trying to have a simple R function to get mRNA expression data dynamically via the API and am unable to do so.