### Install cbioportalR Package Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Provides R code to install the cbioportalR package from CRAN and the development version from GitHub. ```r install.packages("cbioportalR") ``` ```r remotes::install_github("karissawhiting/cbioportalR") ``` -------------------------------- ### Get Panel by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Returns the gene panel used for specific samples. ```APIDOC ## GET /api/panel/by_sample ### Description Returns the gene panel used for specific samples. ### Method GET ### Endpoint /api/panel/by_sample ### Parameters #### Query Parameters - **sample_id** (string) - Required - The ID of the sample. - **study_id** (string) - Required - The ID of the study. ### Request Example ```json { "sample_id": "DS-sig-010-P2", "study_id": "blca_plasmacytoid_mskcc_2016" } ``` ### Response #### Success Response (200) - **data** (object) - Information about the gene panel used for the sample. #### Response Example ```json { "data": { "sampleId": "DS-sig-010-P2", "studyId": "blca_plasmacytoid_mskcc_2016", "genePanel": "IMPACT341" } } ``` ``` -------------------------------- ### Get Segmentation Data by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves segmentation data for specific samples within a study. ```APIDOC ## GET /api/segments/by_sample ### Description Retrieves segmentation data for specific samples. ### Method GET ### Endpoint /api/segments/by_sample ### Parameters #### Query Parameters - **sample_id** (string array) - Required - A list of sample IDs to retrieve data for. - **study_id** (string) - Required - The ID of the study to query. ### Request Example ```json { "sample_id": ["s_C_CAUWT7_P001_d"], "study_id": "prad_msk_2019" } ``` ### Response #### Success Response (200) - **data** (object) - Segmentation data for the requested samples. #### Response Example ```json { "data": { ... segmentation data ... } } ``` ``` -------------------------------- ### Get Clinical Data by Sample Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Retrieves clinical data for specific samples within a study. ```APIDOC ## GET /api/samples/clinical_data ### Description Retrieves clinical data for specific samples within a study. ### Method GET ### Endpoint /api/samples/clinical_data ### Parameters #### Query Parameters - **sample_id** (string) - Required - The ID of the sample(s) to retrieve clinical data for. - **study_id** (string) - Required - The ID of the study. - **clinical_attribute** (string) - Optional - Filters the data to a specific clinical attribute. ### Request Example ```r samples <- c("SAMPLE1", "SAMPLE2") clinical_data <- get_clinical_by_sample(sample_id = samples, study_id = "acc_tcga") ``` ### Response #### Success Response (200) - **data** (list) - A list containing clinical data for the specified samples. #### Response Example ```json [ { "uniqueSampleKey": "VENHQS1PUi1BNUoxLTAxOmFjY190Y2dh", "uniquePatientKey": "VENHQS1PUi1BNUoxLTAxOmFjY190Y2dh", "sampleId": "TCGA-OR-A5K5-01A", "patientId": "TCGA-OR-A5K5", "studyId": "acc_tcga", "clinicalAttributeId": "AGE", "value": "58" } ] ``` ``` -------------------------------- ### Get Mutations by Sample Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Retrieves mutation data for specified samples within a given study. Demonstrates how to handle cases where no results are returned and how to correctly specify the study ID. ```APIDOC ## GET /api/mutations/samples ### Description Retrieves mutation data for specified samples within a given study. Handles cases where no results are returned and demonstrates correct study ID specification. ### Method GET ### Endpoint /api/mutations/samples ### Parameters #### Query Parameters - **sample_id** (string) - Required - The ID of the sample(s) to retrieve mutations for. - **study_id** (string) - Required - The ID of the study. ### Request Example ```r samples <- c("SAMPLE1", "SAMPLE2") mutations <- get_mutations_by_sample(sample_id = samples, study_id = "acc_tcga") ``` ### Response #### Success Response (200) - **mutations** (list) - A list of mutations associated with the provided samples and study. #### Response Example ```json [ { "hugoGeneSymbol": "KRT8", "entrezGeneId": 3856, "uniqueSampleKey": "VENHQS1PUi1BNUoxLTAxOmFjY190Y2dh", "uniquePatientKey": "VENHQS1PUi1BNUoxLTAxOmFjY190Y2dh", "sampleId": "TCGA-OR-A5K5-01A", "patientId": "TCGA-OR-A5K5", "studyId": "acc_tcga", "molecularProfileId": "acc_tcga_mutations", "mutationStatus": "Mutated", "validationStatus": "Valid", "tumorAltCount": 10, "tumorRefCount": 50, "normalAltCount": 0, "normalRefCount": 0, "startPosition": 12345, "endPosition": 12345, "referenceAllele": "A", "variantAllele": "T", "mutationType": "Missense_Mutation", "proteinChange": "p.Val123Ala", "ncbiBuild": "GRCh38", "variantType": "SNP", "chr": "1", "keyword": "Mutation", "center": "Broad", "refseqMrnaId": "NM_002247.3" } ] ``` ``` -------------------------------- ### Get Samples by Patient Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Returns all sample IDs associated with a given patient ID, useful when patients have multiple samples. ```APIDOC ## GET /api/samples/by_patient ### Description Returns all sample IDs associated with a given patient ID. ### Method GET ### Endpoint /api/samples/by_patient ### Parameters #### Query Parameters - **patient_id** (string array) - Required - A list of patient IDs. - **study_id** (string) - Required - The ID of the study. ### Request Example ```json { "patient_id": ["P-0000034", "P-0000036"], "study_id": "msk_impact_2017" } ``` ### Response #### Success Response (200) - **data** (object) - A list of samples associated with the patient IDs. #### Response Example ```json { "data": [ { "patientId": "P-0000034", "sampleId": "P-0000034-T01-IM3", "sampleType": "Primary", "studyId": "msk_impact_2017" }, { "patientId": "P-0000034", "sampleId": "P-0000034-T02-IM5", "sampleType": "Metastasis", "studyId": "msk_impact_2017" } ] } ``` ``` -------------------------------- ### Get Clinical Data by Study Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves all sample-level and patient-level clinical data for a given study. ```APIDOC ## GET /api/clinical/by_study ### Description Retrieves all sample-level and patient-level clinical data for a study. ### Method GET ### Endpoint /api/clinical/by_study ### Parameters #### Query Parameters - **study_id** (string) - Required - The ID of the study. - **clinical_attribute** (string array) - Optional - A list of specific clinical attributes to retrieve. ### Request Example ```json { "study_id": "acc_tcga" } ``` ### Response #### Success Response (200) - **sample_level_data** (object) - Sample-level clinical data. - **patient_level_data** (object) - Patient-level clinical data. #### Response Example ```json { "sample_level_data": { ... }, "patient_level_data": { ... } } ``` ``` -------------------------------- ### Configure cBioPortal Database Connection Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Sets the base URL for the cBioPortal API connection. This function must be called at the start of an R session to establish connectivity. ```R library(cbioportalR) set_cbioportal_db(db = "public") set_cbioportal_db(db = "cbioportal.mskcc.org") set_cbioportal_db(db = "https://www.cbioportal.org") ``` -------------------------------- ### Get Detailed Study Information Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Fetches comprehensive metadata for a specific study, including sample counts and reference genome information. ```R study_info <- get_study_info("acc_tcga") t(study_info) ``` -------------------------------- ### Get Clinical Data by Study Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves all sample-level and patient-level clinical data for a specified study. It can also filter for specific clinical attributes. ```r # Get all clinical data for a study clinical_data <- get_clinical_by_study(study_id = "acc_tcga") clinical_data # Get specific clinical attributes only age_sex <- get_clinical_by_study( study_id = "acc_tcga", clinical_attribute = c("AGE", "SEX") ) ``` -------------------------------- ### Get Clinical Data by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves sample-level clinical data for specific samples, optionally filtering by clinical attributes or querying across multiple studies. ```APIDOC ## GET /api/clinical/by_sample ### Description Retrieves sample-level clinical data for specific samples. ### Method GET ### Endpoint /api/clinical/by_sample ### Parameters #### Query Parameters - **sample_id** (string array) - Required (if `sample_study_pairs` is not provided) - A list of sample IDs. - **study_id** (string) - Required (if `sample_study_pairs` is not provided) - The ID of the study. - **sample_study_pairs** (object array) - Required (if `sample_id` and `study_id` are not provided) - An array of objects, where each object contains `sample_id` and `study_id`. - **clinical_attribute** (string array) - Optional - A list of specific clinical attributes to retrieve. ### Request Example ```json { "sample_id": ["TCGA-OR-A5J2-01", "TCGA-OR-A5J6-01"], "study_id": "acc_tcga", "clinical_attribute": ["CANCER_TYPE", "MUTATION_COUNT", "FRACTION_GENOME_ALTERED"] } ``` ### Response #### Success Response (200) - **data** (object) - Sample-level clinical data. #### Response Example ```json { "data": { ... clinical data ... } } ``` ``` -------------------------------- ### GET /genes/aliases Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves gene aliases for specified HUGO symbols. ```APIDOC ## GET /genes/aliases ### Description Retrieves a list of aliases for the provided HUGO gene symbols. ### Method GET ### Parameters #### Query Parameters - **hugo_symbol** (array) - Required - A vector of HUGO gene symbols to query. ### Request Example get_alias(hugo_symbol = c("FGFR3", "TP53")) ### Response #### Success Response (200) - **hugo_symbol** (string) - The queried symbol - **alias** (string) - The associated alias #### Response Example [{"hugo_symbol": "FGFR3", "alias": "ACH"}, {"hugo_symbol": "TP53", "alias": "p53"}] ``` -------------------------------- ### Get Genes Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Returns a list of all genes available in the cBioPortal database with their Entrez IDs and Hugo symbols. ```APIDOC ## GET /api/genes ### Description Returns a list of all genes available in the cBioPortal database. ### Method GET ### Endpoint /api/genes ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **data** (array) - A list of gene objects, each containing `entrezGeneId`, `hugoGeneSymbol`, and `type`. #### Response Example ```json { "data": [ { "entrezGeneId": 1, "hugoGeneSymbol": "A1BG", "type": "protein-coding" }, { "entrezGeneId": 2, "hugoGeneSymbol": "A2M", "type": "protein-coding" } ] } ``` ``` -------------------------------- ### GET /get_mutations_by_sample Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Retrieves mutation data for specific samples within a cBioPortal study. This endpoint requires sample identifiers and associated study identifiers to filter genomic data effectively. ```APIDOC ## GET /get_mutations_by_sample ### Description Retrieves mutation data for a list of samples. If study_id is not provided, the system defaults to the public IMPACT database (msk_impact_2017). ### Method GET ### Endpoint /get_mutations_by_sample ### Parameters #### Query Parameters - **sample_id** (array) - Required - A list of sample identifiers to query. - **study_id** (string) - Optional - The study identifier where the samples are housed. Defaults to 'msk_impact_2017'. - **molecular_profile_id** (string) - Optional - The specific molecular profile to query. ### Request Example { "sample_id": ["TCGA-OR-A5J1-01"], "study_id": "acc_tcga" } ### Response #### Success Response (200) - **data** (table) - A dataframe containing gene symbols, Entrez IDs, molecular profile IDs, sample IDs, patient IDs, study IDs, and alteration counts. #### Response Example { "gene": "FRS2", "entrez_gene_id": 10818, "sampleId": "TCGA-OR-A5J1-01", "alteration": 1 } ``` -------------------------------- ### GET /gene-panels/{panel_id} Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves detailed information about genes included in a specific gene panel. ```APIDOC ## GET /gene-panels/{panel_id} ### Description Returns detailed information about genes included in a specific gene panel or multiple panels. ### Method GET ### Parameters #### Path Parameters - **panel_id** (string/array) - Required - The ID or list of IDs of the gene panels. ### Request Example get_gene_panel(panel_id = "IMPACT468") ### Response #### Success Response (200) - **genePanelId** (string) - The panel identifier - **entrezGeneId** (integer) - The Entrez ID of the gene - **hugoGeneSymbol** (string) - The HUGO symbol - **description** (string) - Panel description #### Response Example [{"genePanelId": "IMPACT468", "entrezGeneId": 25, "hugoGeneSymbol": "ABL1", "description": "MSK-IMPACT"}] ``` -------------------------------- ### Get Gene Aliases Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Returns known gene aliases for a given Hugo Symbol. ```APIDOC ## GET /api/genes/alias ### Description Returns known gene aliases for a given Hugo Symbol. ### Method GET ### Endpoint /api/genes/alias ### Parameters #### Query Parameters - **hugo_symbol** (string) - Required - The Hugo Symbol for which to retrieve aliases. ### Request Example ```json { "hugo_symbol": "FGFR1" } ``` ### Response #### Success Response (200) - **data** (array) - A list of gene aliases for the given Hugo Symbol. #### Response Example ```json { "data": ["CDK5RAP2", "FLG", "FLJ107583", "FLJ11057", "FLJ11124", "FLJ11210", "FLJ11287", "FLJ11307", "FLJ11347", "FLJ11423", "FLJ11535", "FLJ11668", "FLJ11731", "FLJ11840", "FLJ11934", "FLJ12171", "FLJ12267", "FLJ12300", "FLJ12314", "FLJ12320", "FLJ12340", "FLJ12377", "FLJ12411", "FLJ12431", "FLJ12445", "FLJ12476", "FLJ12500", "FLJ12509", "FLJ12510", "FLJ12513", "FLJ12515", "FLJ12517", "FLJ12519", "FLJ12521", "FLJ12523", "FLJ12525", "FLJ12527", "FLJ12529", "FLJ12531", "FLJ12533", "FLJ12535", "FLJ12537", "FLJ12539", "FLJ12541", "FLJ12543", "FLJ12545", "FLJ12547", "FLJ12549", "FLJ12551", "FLJ12553", "FLJ12555", "FLJ12557", "FLJ12559", "FLJ12561", "FLJ12563", "FLJ12565", "FLJ12567", "FLJ12569", "FLJ12571", "FLJ12573", "FLJ12575", "FLJ12577", "FLJ12579", "FLJ12581", "FLJ12583", "FLJ12585", "FLJ12587", "FLJ12589", "FLJ12591", "FLJ12593", "FLJ12595", "FLJ12597", "FLJ12599", "FLJ12601", "FLJ12603", "FLJ12605", "FLJ12607", "FLJ12609", "FLJ12611", "FLJ12613", "FLJ12615", "FLJ12617", "FLJ12619", "FLJ12621", "FLJ12623", "FLJ12625", "FLJ12627", "FLJ12629", "FLJ12631", "FLJ12633", "FLJ12635", "FLJ12637", "FLJ12639", "FLJ12641", "FLJ12643", "FLJ12645", "FLJ12647", "FLJ12649", "FLJ12651", "FLJ12653", "FLJ12655", "FLJ12657", "FLJ12659", "FLJ12661", "FLJ12663", "FLJ12665", "FLJ12667", "FLJ12669", "FLJ12671", "FLJ12673", "FLJ12675", "FLJ12677", "FLJ12679", "FLJ12681", "FLJ12683", "FLJ12685", "FLJ12687", "FLJ12689", "FLJ12691", "FLJ12693", "FLJ12695", "FLJ12697", "FLJ12699", "FLJ12701", "FLJ12703", "FLJ12705", "FLJ12707", "FLJ12709", "FLJ12711", "FLJ12713", "FLJ12715", "FLJ12717", "FLJ12719", "FLJ12721", "FLJ12723", "FLJ12725", "FLJ12727", "FLJ12729", "FLJ12731", "FLJ12733", "FLJ12735", "FLJ12737", "FLJ12739", "FLJ12741", "FLJ12743", "FLJ12745", "FLJ12747", "FLJ12749", "FLJ12751", "FLJ12753", "FLJ12755", "FLJ12757", "FLJ12759", "FLJ12761", "FLJ12763", "FLJ12765", "FLJ12767", "FLJ12769", "FLJ12771", "FLJ12773", "FLJ12775", "FLJ12777", "FLJ12779", "FLJ12781", "FLJ12783", "FLJ12785", "FLJ12787", "FLJ12789", "FLJ12791", "FLJ12793", "FLJ12795", "FLJ12797", "FLJ12799", "FLJ12801", "FLJ12803", "FLJ12805", "FLJ12807", "FLJ12809", "FLJ12811", "FLJ12813", "FLJ12815", "FLJ12817", "FLJ12819", "FLJ12821", "FLJ12823", "FLJ12825", "FLJ12827", "FLJ12829", "FLJ12831", "FLJ12833", "FLJ12835", "FLJ12837", "FLJ12839", "FLJ12841", "FLJ12843", "FLJ12845", "FLJ12847", "FLJ12849", "FLJ12851", "FLJ12853", "FLJ12855", "FLJ12857", "FLJ12859", "FLJ12861", "FLJ12863", "FLJ12865", "FLJ12867", "FLJ12869", "FLJ12871", "FLJ12873", "FLJ12875", "FLJ12877", "FLJ12879", "FLJ12881", "FLJ12883", "FLJ12885", "FLJ12887", "FLJ12889", "FLJ12891", "FLJ12893", "FLJ12895", "FLJ12897", "FLJ12899", "FLJ12901", "FLJ12903", "FLJ12905", "FLJ12907", "FLJ12909", "FLJ12911", "FLJ12913", "FLJ12915", "FLJ12917", "FLJ12919", "FLJ12921", "FLJ12923", "FLJ12925", "FLJ12927", "FLJ12929", "FLJ12931", "FLJ12933", "FLJ12935", "FLJ12937", "FLJ12939", "FLJ12941", "FLJ12943", "FLJ12945", "FLJ12947", "FLJ12949", "FLJ12951", "FLJ12953", "FLJ12955", "FLJ12957", "FLJ12959", "FLJ12961", "FLJ12963", "FLJ12965", "FLJ12967", "FLJ12969", "FLJ12971", "FLJ12973", "FLJ12975", "FLJ12977", "FLJ12979", "FLJ12981", "FLJ12983", "FLJ12985", "FLJ12987", "FLJ12989", "FLJ12991", "FLJ12993", "FLJ12995", "FLJ12997", "FLJ12999", "FLJ13001", "FLJ13003", "FLJ13005", "FLJ13007", "FLJ13009", "FLJ13011", "FLJ13013", "FLJ13015", "FLJ13017", "FLJ13019", "FLJ13021", "FLJ13023", "FLJ13025", "FLJ13027", "FLJ13029", "FLJ13031", "FLJ13033", "FLJ13035", "FLJ13037", "FLJ13039", "FLJ13041", "FLJ13043", "FLJ13045", "FLJ13047", "FLJ13049", "FLJ13051", "FLJ13053", "FLJ13055", "FLJ13057", "FLJ13059", "FLJ13061", "FLJ13063", "FLJ13065", "FLJ13067", "FLJ13069", "FLJ13071", "FLJ13073", "FLJ13075", "FLJ13077", "FLJ13079", "FLJ13081", "FLJ13083", "FLJ13085", "FLJ13087", "FLJ13089", "FLJ13091", "FLJ13093", "FLJ13095", "FLJ13097", "FLJ13099", "FLJ13101", "FLJ13103", "FLJ13105", "FLJ13107", "FLJ13109", "FLJ13111", "FLJ13113", "FLJ13115", "FLJ13117", "FLJ13119", "FLJ13121", "FLJ13123", "FLJ13125", "FLJ13127", "FLJ13129", "FLJ13131", "FLJ13133", "FLJ13135", "FLJ13137", "FLJ13139", "FLJ13141", "FLJ13143", "FLJ13145", "FLJ13147", "FLJ13149", "FLJ13151", "FLJ13153", "FLJ13155", "FLJ13157", "FLJ13159", "FLJ13161", "FLJ13163", "FLJ13165", "FLJ13167", "FLJ13169", "FLJ13171", "FLJ13173", "FLJ13175", "FLJ13177", "FLJ13179", "FLJ13181", "FLJ13183", "FLJ13185", "FLJ13187", "FLJ13189", "FLJ13191", "FLJ13193", "FLJ13195", "FLJ13197", "FLJ13199", "FLJ13201", "FLJ13203", "FLJ13205", "FLJ13207", "FLJ13209", "FLJ13211", "FLJ13213", "FLJ13215", "FLJ13217", "FLJ13219", "FLJ13221", "FLJ13223", "FLJ13225", "FLJ13227", "FLJ13229", "FLJ13231", "FLJ13233", "FLJ13235", "FLJ13237", "FLJ13239", "FLJ13241", "FLJ13243", "FLJ13245", "FLJ13247", "FLJ13249", "FLJ13251", "FLJ13253", "FLJ13255", "FLJ13257", "FLJ13259", "FLJ13261", "FLJ13263", "FLJ13265", "FLJ13267", "FLJ13269", "FLJ13271", "FLJ13273", "FLJ13275", "FLJ13277", "FLJ13279", "FLJ13281", "FLJ13283", "FLJ13285", "FLJ13287", "FLJ13289", "FLJ13291", "FLJ13293", "FLJ13295", "FLJ13297", "FLJ13299", "FLJ13301", "FLJ13303", "FLJ13305", "FLJ13307", "FLJ13309", "FLJ13311", "FLJ13313", "FLJ13315", "FLJ13317", "FLJ13319", "FLJ13321", "FLJ13323", "FLJ13325", "FLJ13327", "FLJ13329", "FLJ13331", "FLJ13333", "FLJ13335", "FLJ13337", "FLJ13339", "FLJ13341", "FLJ13343", "FLJ13345", "FLJ13347", "FLJ13349", "FLJ13351", "FLJ13353", "FLJ13355", "FLJ13357", "FLJ13359", "FLJ13361", "FLJ13363", "FLJ13365", "FLJ13367", "FLJ13369", "FLJ13371", "FLJ13373", "FLJ13375", "FLJ13377", "FLJ13379", "FLJ13381", "FLJ13383", "FLJ13385", "FLJ13387", "FLJ13389", "FLJ13391", "FLJ13393", "FLJ13395", "FLJ13397", "FLJ13399", "FLJ13401", "FLJ13403", "FLJ13405", "FLJ13407", "FLJ13409", "FLJ13411", "FLJ13413", "FLJ13415", "FLJ13417", "FLJ13419", "FLJ13421", "FLJ13423", "FLJ13425", "FLJ1 ``` -------------------------------- ### Get Clinical Data by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves sample-level clinical data for specific sample IDs within a given study. It supports fetching all attributes or specific ones, and can query across multiple studies using sample-study pairs. ```r # Get clinical data for specific samples samples <- c("TCGA-OR-A5J2-01", "TCGA-OR-A5J6-01") clinical <- get_clinical_by_sample( sample_id = samples, study_id = "acc_tcga" ) # Get specific attributes clinical <- get_clinical_by_sample( sample_id = samples, study_id = "acc_tcga", clinical_attribute = c("CANCER_TYPE", "MUTATION_COUNT", "FRACTION_GENOME_ALTERED") ) # Query across multiple studies using sample_study_pairs df_pairs <- data.frame( sample_id = c("P-0001453-T01-IM3", "P-0002166-T01-IM3", "s_C_36924L_P001_d"), study_id = c("blca_nmibc_2017", "blca_nmibc_2017", "prad_msk_2019") ) multi_study_clinical <- get_clinical_by_sample(sample_study_pairs = df_pairs) ``` -------------------------------- ### Get Segmentation Data by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves segmentation data for specified sample IDs within a given study. This is useful for analyzing copy number alterations. ```r segments <- get_segments_by_sample( sample_id = c("s_C_CAUWT7_P001_d"), study_id = "prad_msk_2019" ) ``` -------------------------------- ### Direct cBioPortal API Access with cbp_api Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Provides low-level access to the cBioPortal API for custom queries. Supports both GET and POST requests, allowing for flexible data retrieval beyond the standard wrapper functions. Requires specifying the URL path, method, and optionally a base URL and request body. ```r # Direct API call - GET request result <- cbp_api( url_path = "genes/TP53", base_url = "public" ) result$content #> $entrezGeneId #> [1] 7157 #> $hugoGeneSymbol #> [1] "TP53" #> $type #> [1] "protein-coding" # POST request with body result <- cbp_api( url_path = "genes/fetch?geneIdType=HUGO_GENE_SYMBOL", method = "post", body = c("TP53", "BRCA1", "BRCA2"), base_url = "public" ) # Access raw API response result$response$status_code result$path ``` -------------------------------- ### Get Samples by Patient Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Returns all sample IDs associated with a given patient ID within a specific study. This is useful for identifying all samples belonging to a single patient. ```r # Get all samples for specific patients samples <- get_samples_by_patient( patient_id = c("P-0000034", "P-0000036"), study_id = "msk_impact_2017" ) samples ``` -------------------------------- ### Get Entrez ID from Hugo Symbol Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Converts Hugo Symbols to Entrez Gene IDs. ```APIDOC ## GET /api/genes/entrez_id ### Description Converts Hugo Symbols to Entrez Gene IDs. ### Method GET ### Endpoint /api/genes/entrez_id ### Parameters #### Query Parameters - **hugo_symbol** (string array) - Required - A list of Hugo Symbols. ### Request Example ```json { "hugo_symbol": ["FGFR1", "TP53"] } ``` ### Response #### Success Response (200) - **data** (array) - A list of gene objects, each containing `entrezGeneId`, `hugoGeneSymbol`, and `type`. #### Response Example ```json { "data": [ { "entrezGeneId": 2260, "hugoGeneSymbol": "FGFR1", "type": "protein-coding" }, { "entrezGeneId": 7157, "hugoGeneSymbol": "TP53", "type": "protein-coding" } ] } ``` ``` -------------------------------- ### Get Hugo Symbol from Entrez ID Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Converts Entrez Gene IDs to Hugo Symbols. ```APIDOC ## GET /api/genes/hugo_symbol ### Description Converts Entrez Gene IDs to Hugo Symbols. ### Method GET ### Endpoint /api/genes/hugo_symbol ### Parameters #### Query Parameters - **entrez_id** (string array) - Required - A list of Entrez Gene IDs. ### Request Example ```json { "entrez_id": ["2261", "7157"] } ``` ### Response #### Success Response (200) - **data** (array) - A list of gene objects, each containing `entrezGeneId`, `hugoGeneSymbol`, and `type`. #### Response Example ```json { "data": [ { "entrezGeneId": 2261, "hugoGeneSymbol": "FGFR3", "type": "protein-coding" }, { "entrezGeneId": 7157, "hugoGeneSymbol": "TP53", "type": "protein-coding" } ] } ``` ``` -------------------------------- ### Get Gene Panel by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves the gene panel information used for sequencing specific samples within a given study. This helps in understanding the scope of genomic data available for a sample. ```r # Get gene panel information for samples panel_info <- get_panel_by_sample( sample_id = "DS-sig-010-P2", study_id = "blca_plasmacytoid_mskcc_2016" ) panel_info ``` -------------------------------- ### Get Clinical Data by Patient Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves patient-level clinical data for specific patients, optionally filtering by clinical attributes or querying across multiple studies. ```APIDOC ## GET /api/clinical/by_patient ### Description Retrieves patient-level clinical data for specific patients. ### Method GET ### Endpoint /api/clinical/by_patient ### Parameters #### Query Parameters - **patient_id** (string array) - Required (if `patient_study_pairs` is not provided) - A list of patient IDs. - **study_id** (string) - Required (if `patient_study_pairs` is not provided) - The ID of the study. - **patient_study_pairs** (object array) - Required (if `patient_id` and `study_id` are not provided) - An array of objects, where each object contains `patient_id` and `study_id`. - **clinical_attribute** (string array) - Optional - A list of specific clinical attributes to retrieve. ### Request Example ```json { "patient_id": ["TCGA-OR-A5J2", "TCGA-OR-A5J6"], "study_id": "acc_tcga", "clinical_attribute": "AGE" } ``` ### Response #### Success Response (200) - **data** (object) - Patient-level clinical data. #### Response Example ```json { "data": { ... clinical data ... } } ``` ``` -------------------------------- ### Get Gene Aliases Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves known gene aliases for a given Hugo Symbol. This can be helpful for identifying alternative names used for a gene in different contexts. ```r # Get gene alias information for a gene # Note: The actual function call for get_alias is missing in the provided text. ``` -------------------------------- ### Get All Genes Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves a comprehensive list of all genes available in the cBioPortal database, including their Entrez Gene IDs and Hugo Symbols. This function is useful for exploring the gene universe covered by cBioPortal. ```r # Get all genes in the database all_genes <- get_genes() all_genes ``` -------------------------------- ### Get Gene Panel Information using cbioportalR Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Fetches detailed information about genes included in a specified gene panel. Supports retrieving genes for a single panel or multiple panels by providing a vector of panel IDs. ```r # Get genes in a panel impact_genes <- get_gene_panel(panel_id = "IMPACT468") impact_genes #> # A tibble: 468 × 4 #> genePanelId entrezGeneId hugoGeneSymbol description #> #> 1 IMPACT468 25 ABL1 MSK-IMPACT (468 genes) #> 2 IMPACT468 238 ALK MSK-IMPACT (468 genes) #> # ℹ more rows # Get multiple panels panels <- get_gene_panel(panel_id = c("IMPACT468", "IMPACT341")) ``` -------------------------------- ### Get Clinical Data by Patient Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves patient-level clinical data for specific patient IDs within a given study. This function can fetch all attributes or specific ones and supports querying across multiple studies using patient-study pairs. ```r # Get clinical data for specific patients patients <- c("TCGA-OR-A5J2", "TCGA-OR-A5J6") clinical <- get_clinical_by_patient( patient_id = patients, study_id = "acc_tcga", clinical_attribute = "AGE" ) # Query across multiple studies patient_pairs <- data.frame( patient_id = c("P-0001453", "P-0002166", "P-0000004"), study_id = c("blca_nmibc_2017", "blca_nmibc_2017", "msk_impact_2017") ) multi_clinical <- get_clinical_by_patient( patient_study_pairs = patient_pairs, clinical_attribute = c("AGE", "SEX") ) ``` -------------------------------- ### Get Genomic Data by Study ID in R Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md This function retrieves all available genomic data (mutations, CNA, and optionally fusion data) for a given study ID from cBioPortal. It returns a list of data frames, one for each data type. Note that fusion data may not be available for all studies. ```r df <- get_genetics_by_study(study_id = "acc_tcga") ``` -------------------------------- ### Get Specific Study Metadata in R Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md This R code snippet shows how to fetch detailed metadata for a specific study, identified by its ID (e.g., 'acc_tcga'). It uses the `get_study_info()` function and then transposes the resulting list into a matrix for easier viewing of the study's properties and their values. ```r get_study_info("acc_tcga") %>% t() ``` -------------------------------- ### Get Gene Aliases using cbioportalR Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Retrieves alternative gene symbols (aliases) for given HUGO gene symbols. This function is useful for mapping gene identifiers and ensuring comprehensive data analysis. ```r aliases <- get_alias(hugo_symbol = c("FGFR3", "TP53")) aliasest #> # A tibble: 6 × 2 #> hugo_symbol alias #> #> 1 FGFR3 ACH #> 2 FGFR3 CD333 #> 3 TP53 p53 #> 4 TP53 LFS1 ``` -------------------------------- ### Configure R Environment Variables Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Opens the .Renviron file for editing and demonstrates the format for storing the CBIOPORTAL_TOKEN environment variable. ```r usethis::edit_r_environ() CBIOPORTAL_TOKEN = 'YOUR_TOKEN' ``` -------------------------------- ### Set and Test Database Connection Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Configures the target cBioPortal database URL and verifies the connection status to ensure API calls will succeed. ```r set_cbioportal_db(db = "public") test_cbioportal_db() ``` -------------------------------- ### Authentication and Database Connection Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Functions for setting up the cBioPortal database connection and handling authentication tokens. ```APIDOC ## Authentication and Database Connection ### set_cbioportal_db Sets the cBioPortal database URL for the current R session. This function must be called at the start of each session to establish the connection to the cBioPortal API. It validates the connection and stores the URL as an environment variable for all subsequent API calls. ### Method `set_cbioportal_db` ### Parameters #### Query Parameters - **db** (string) - Required - The URL or identifier for the cBioPortal database (e.g., "public", "cbioportal.mskcc.org", "https://www.cbioportal.org"). ### Request Example ```R library(cbioportalR) # Connect to the public cBioPortal database set_cbioportal_db(db = "public") #> ✔ You are successfully connected! #> ✔ base_url for this R session is now set to "www.cbioportal.org/api" # Or connect to a private institutional instance set_cbioportal_db(db = "cbioportal.mskcc.org") # Using full URL set_cbioportal_db(db = "https://www.cbioportal.org") ``` ### get_cbioportal_token Retrieves the cBioPortal authentication token from the CBIOPORTAL_TOKEN environment variable stored in .Renviron. This is required only for private cBioPortal instances that require authentication. ### Method `get_cbioportal_token` ### Parameters None ### Request Example ```R # Check if token is properly configured token <- get_cbioportal_token() # If no token is found, you'll receive a warning # To set up a token, add to your .Renviron file: # CBIOPORTAL_TOKEN = 'your_token_here' # You can easily open .Renviron with: # usethis::edit_r_environ() ``` ### test_cbioportal_db Tests the current database connection at any point during your R session. Useful for troubleshooting API issues or verifying connectivity after network changes. ### Method `test_cbioportal_db` ### Parameters None ### Request Example ```R # Verify connection is still active test_cbioportal_db() #> ✔ You are successfully connected! ``` ``` -------------------------------- ### Retrieve Mutations by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Fetches mutation data for specific samples with options to filter by Hugo symbol, Entrez ID, or gene panel. ```R mutations <- get_mutations_by_sample(sample_id = c("TCGA-OR-A5J2-01", "TCGA-OR-A5J6-01"), study_id = "acc_tcga") tp53_mutations <- get_mutations_by_sample(sample_id = c("TCGA-OR-A5J2-01", "TCGA-OR-A5J6-01"), study_id = "acc_tcga", genes = "TP53") ``` -------------------------------- ### Verify Authentication Token Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Checks if the cBioPortal token has been correctly loaded into the current R session environment. ```r get_cbioportal_token() ``` -------------------------------- ### Verify Database Connection Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Tests the current active connection to the cBioPortal database. Useful for troubleshooting and ensuring the API is reachable. ```R test_cbioportal_db() ``` -------------------------------- ### Available Samples API Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Lists the samples available within a specified study. ```APIDOC ## GET /api/studies/{study_id}/samples ### Description Lists the samples available within a specified study. ### Method GET ### Endpoint /api/studies/{study_id}/samples ### Parameters #### Path Parameters - **study_id** (string) - Required - The ID of the study to retrieve samples from. ### Request Example ```r available_samples <- available_samples(study_id = "acc_tcga") ``` ### Response #### Success Response (200) - **samples** (list) - A list of available samples within the study. #### Response Example ```json [ "SAMPLE1", "SAMPLE2", "SAMPLE3" ] ``` ``` -------------------------------- ### Load cbioportalR Package Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md R code to load the cbioportalR package into the current R session for use. ```r library(cbioportalR) ``` -------------------------------- ### Retrieve CNA Data by Sample Source: https://context7.com/karissawhiting/cbioportalr/llms.txt Fetches CNA data for specific samples, with optional filtering for specific oncogenes. ```R cna_data <- get_cna_by_sample(sample_id = c("s_C_36924L_P001_d"), study_id = "prad_msk_2019") onco_cna <- get_cna_by_sample(sample_id = c("s_C_36924L_P001_d"), study_id = "prad_msk_2019", genes = c("AR", "MYC", "PTEN", "RB1")) ``` -------------------------------- ### Retrieve Mutations by Sample Source: https://github.com/karissawhiting/cbioportalr/blob/main/README.md Fetches mutation data for specified samples within a given study ID. It returns a tibble containing genomic details like gene symbols and mutation types. ```R mutations <- get_mutations_by_sample(sample_id = samples, study_id = "acc_tcga") mutations %>% head() ```