#Using R to interface with the cBioPortal#
Last active
October 25, 2015 22:05
-
-
Save ahmedmoustafa/761f5a29b59a8ccaef14 to your computer and use it in GitHub Desktop.
Using R to interface with the cBioPortal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library (cgdsr) | |
| # Create a connection to the cBioPortal for Cancer Genomics | |
| mycgds = CGDS("http://www.cbioportal.org/public-portal/") | |
| # Test the connection | |
| test(mycgds) | |
| # Instead of going through the 80-something studies, | |
| # let's focus on the TCGA datasets (shown in the text file below) | |
| library(RCurl) | |
| url = getURL("http://bit.ly/tcga_study_ids", followlocation = TRUE) | |
| tcga_studies = as.matrix(read.table(text = url)) | |
| # Create a list of cancer-related genes | |
| # The names of the genes must follow HUGO Gene Nomenclature Committee | |
| # HGNC (http://www.genenames.org/) | |
| genes = c("EGFR", "HER1", "MYC", "RB1", "TP53", "PTEN") | |
| # Empty dataset for holding the expression values | |
| exps = NULL | |
| # For each study: | |
| for (i in 1 : length(tcga_studies)) { | |
| # Obtain the study id | |
| study_id = tcga_studies[i] | |
| # Build the mRNA profile (based on the study id) | |
| profile_mrna = paste(study_id, "rna_seq_v2_mrna_median_Zscores", sep = "_") | |
| # Select the "completely" analyzed cancer samples | |
| # i.e., mRNA expression, copy number variation, and mutations | |
| case = paste(study_id, "3way_complete", sep = "_") | |
| # Empty vector for the means of the genes in the current study | |
| means = NULL | |
| # For each gene: | |
| for (j in 1 : length(genes)) { | |
| # Retrieve expression data from the server | |
| mrna = getProfileData(mycgds, genes[j], profile_mrna, case) | |
| # Compute the mean of the expression values for the current gene | |
| means = c(means, mean(mrna[,1])) | |
| } | |
| # Add a row to the table of the genes | |
| exps = rbind(exps, means) | |
| } | |
| row.names(exps) = tcga_studies | |
| colnames(exps) = genes | |
| # Boxplot for the means of the genes of interest in the different cancer types | |
| boxplot (exps) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| acc_tcga | |
| blca_tcga | |
| blca_tcga_pub | |
| brca_tcga | |
| cesc_tcga | |
| coadread_tcga | |
| gbm_tcga | |
| gbm_tcga_pub2013 | |
| hnsc_tcga | |
| hnsc_tcga_pub | |
| kich_tcga | |
| kirc_tcga | |
| kirc_tcga_pub | |
| kirp_tcga | |
| laml_tcga | |
| laml_tcga_pub | |
| lgg_tcga | |
| luad_tcga | |
| luad_tcga_pub | |
| lusc_tcga | |
| ov_tcga | |
| paad_tcga | |
| prad_tcga | |
| skcm_tcga | |
| stad_tcga | |
| stad_tcga_pub | |
| thca_tcga | |
| ucec_tcga_pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment