<jupyter_start><jupyter_text>Table of ContentsDependenciesPathsMainAdd tumour subtypesATRT and MBGBM subgroupsCBTNICGCEPN subgroupsNBL subgroupsLGG subgroups  Dependencies<jupyter_code>library(maftools)<jupyter_output><empty_output><jupyter_text>Paths<jupyter_code>manifestpath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Manifests/"
datapath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Data/"
plotpath <- "/Users/anabbi/OneDrive - UHN/Documents/IPD2/Plots/"<jupyter_output><empty_output><jupyter_text>Main<jupyter_code>load(paste0(datapath, "ESTIMATE/estimate_manifest_primary_clean_final.RData"))
table(estimate_manifest_primary_clean$group)
metadata <- estimate_manifest_primary_clean<jupyter_output><empty_output><jupyter_text>Add tumour subtypes<jupyter_code>metadata$tumour_subtype <- NA<jupyter_output><empty_output><jupyter_text>ATRT and MB from ICGC or gene expression clustering<jupyter_code>metadata$tumour_subtype[ metadata$cohort == "MB"] <- metadata$disease_type[ metadata$cohort == "MB"]
table(metadata$tumour_subtype)
# some cleanup
metadata$tumour_subtype[metadata$tumour_subtype == "MB_Group3"] <- "MB_GR34"
metadata$tumour_subtype[metadata$tumour_subtype == "MB_Group4"] <- "MB_GR34"
table(metadata$tumour_subtype)
metadata$tumour_subtype[ metadata$cohort == "ATRT"] <- metadata$disease_type[ metadata$cohort == "ATRT"]<jupyter_output><empty_output><jupyter_text>GBM subgroups  CBTN The following is to add variantfilenames to oncokb annotated combined_maf using CBTTC_summary_mutations_MuTect2.txt (generated on cavatica)<jupyter_code>CBTN_mafsummary <- read.table(file = paste0(datapath,"snv/CBTTC_mafsummary_overlapped_3VAF.txt"),
                              sep = "\t", check.names = F, header = TRUE,  stringsAsFactors = FALSE)
head(CBTN_mafsummary)
dim(CBTN_mafsummary)
mymaf_CBTN <- read.maf(maf =  paste0(datapath,"snv/CBTTC_maf_overlapped_3VAF.maf"),
                       useAll = TRUE, verbose = FALSE,
                       vc_nonSyn = c("Frame_Shift_Del", "Frame_Shift_Ins", "Nonsense_Mutation","Nonstop_Mutation", 
                                     "In_Frame_Del","In_Frame_Ins", "Missense_Mutation"))
mymaf_CBTN@summary
CBTN_data_maf <- mymaf_CBTN@data
CBTN_data_maf_sampleid <- merge(CBTN_mafsummary[,c("sample_id", "Tumor_Sample_Barcode")],
                                CBTN_data_maf,by = "Tumor_Sample_Barcode")
length(unique(CBTN_data_maf_sampleid$Tumor_Sample_Barcode))<jupyter_output><empty_output><jupyter_text>Subset  snv dfs to include only samples in estimate df<jupyter_code>CBTN_data_maf_primary <- CBTN_data_maf_sampleid[CBTN_data_maf_sampleid$sample_id %in% metadata$sample_id,]
length(unique(CBTN_data_maf_primary$Tumor_Sample_Barcode))
head(CBTN_data_maf_primary)
cbtn_h3f3a <- CBTN_data_maf_primary[which(CBTN_data_maf_primary$Hugo_Symbol == "H3F3A"),]
cbtn_idh1 <- CBTN_data_maf_primary[which(CBTN_data_maf_primary$Hugo_Symbol == "IDH1"),]
cbtn_h3f3a_k27 <- cbtn_h3f3a[which(grepl("K28M", cbtn_h3f3a$HGVSp_Short)),]
cbtn_h3f3a_g34 <- cbtn_h3f3a[which(grepl("G35", cbtn_h3f3a$HGVSp_Short)),]
k27_samples <- cbtn_h3f3a_k27$sample_id
g34_samples <- cbtn_h3f3a_g34$sample_id
idh1_samples <- cbtn_idh1$sample_id
metadata$tumour_subtype[metadata$sample_id %in% idh1_samples &
                        metadata$cohort == "pedHGG" & metadata$group == "CBTN"] <- "HGG_IDH1"
metadata$tumour_subtype[metadata$sample_id %in% g34_samples &
                        metadata$cohort == "pedHGG"& metadata$group == "CBTN"] <- "HGG_G34"
metadata$tumour_subtype[metadata$sample_id %in% k27_samples &
                        metadata$cohort == "pedHGG"& metadata$group == "CBTN"] <- "HGG_K27M"
metadata$tumour_subtype[is.na(metadata$tumour_subtype) &
                        metadata$cohort == "pedHGG"& metadata$group == "CBTN"] <- "HGG_WT"<jupyter_output><empty_output><jupyter_text>ICGCGet DKFZ tumour subtypes from clinical metadata<jupyter_code>metadata$tumour_subtype[metadata$cohort == "pedHGG" & metadata$group == "ICGC"] <- 
metadata$disease_type[metadata$cohort == "pedHGG" & metadata$group == "ICGC"]
metadata$disease_type[metadata$cohort == "pedHGG" & metadata$group == "ICGC"]
metadata$tumour_subtype[grepl("HGGother_IDH", metadata$tumour_subtype)] <- "HGG_IDH1"
metadata$tumour_subtype[grepl("HGG_K27M", metadata$tumour_subtype)] <- "HGG_K27M"
metadata$tumour_subtype[grepl("HGGother_G34R", metadata$tumour_subtype)] <- "HGG_G34"
metadata$tumour_subtype[grepl("HGGother_WT", metadata$tumour_subtype)] <- "HGG_WT"<jupyter_output><empty_output><jupyter_text>EPN subgroups<jupyter_code>EPNs <- metadata[metadata$cohort == "EPN",]
table(EPNs$primary_site)
epn_fossa <- EPNs$sample_id[grepl("Posterior Fossa", EPNs$primary_site)]
epn_spine <- EPNs$sample_id[grepl("Spin", EPNs$primary_site)]
epn_supratent <- EPNs$sample_id[grepl("Lobe", EPNs$primary_site) | grepl("Ventricle", EPNs$primary_site)]
metadata$tumour_subtype[metadata$sample_id %in% epn_fossa & metadata$cohort == "EPN"] <- "EPN_Fossa"
metadata$tumour_subtype[metadata$sample_id %in% epn_spine & metadata$cohort == "EPN"] <- "EPN_Spine"
metadata$tumour_subtype[metadata$sample_id %in% epn_supratent & metadata$cohort == "EPN"] <- "EPN_Supra"
metadata$tumour_subtype[is.na(metadata$tumour_subtype) & metadata$cohort == "EPN"] <- "EPN_ND"<jupyter_output><empty_output><jupyter_text>NBL subgroups From TARGET portal<jupyter_code>NBLs <- metadata[metadata$cohort == "NBL",]
NBL_manifest <- read.table(paste0(manifestpath, "TARGET_NBL_Discovery_ClinicalData_20170525.txt"),
                          sep = "\t", na.strings = "", header = TRUE)
colnames(NBL_manifest)[colnames(NBL_manifest) == "TARGET.USI"] <- "case_id"
NBL_manifest_subset <- NBL_manifest[NBL_manifest$case_id %in% NBLs$case_id,]
dim(NBL_manifest_subset)
NBLs_MYCstatus <- merge(NBLs, NBL_manifest_subset[, c("case_id", "MYCN.status")], by = "case_id")
dim(NBLs_MYCstatus)
table(NBLs_MYCstatus$MYCN.status)
head(NBLs_MYCstatus)
nbl_myca <- NBLs_MYCstatus$case_id[NBLs_MYCstatus$MYCN.status == "Amplified"]
nbl_mycna <- NBLs_MYCstatus$case_id[NBLs_MYCstatus$MYCN.status == "Not Amplified"]
metadata$tumour_subtype[metadata$case_id %in% nbl_myca & metadata$cohort == "NBL"] <- "NBL_MYCA"
metadata$tumour_subtype[metadata$case_id %in% nbl_mycna & metadata$cohort == "NBL"] <- "NBL_MYCNA"
metadata$tumour_subtype[is.na(metadata$tumour_subtype)& metadata$cohort == "NBL"] <- "NBL_ND"
table(metadata$tumour_subtype[which(metadata$cohort == "NBL")])<jupyter_output><empty_output><jupyter_text>LGG subgroups Add BRAF status<jupyter_code>load(file = paste0(datapath, "fusion/arriba_df.RData"))<jupyter_output><empty_output><jupyter_text>remove low confidence<jupyter_code>arriba_df_conf <- arriba_df[arriba_df$confidence != "low",]
braf_fusion_samples <- arriba_df_conf$sample_id[grepl("BRAF", arriba_df_conf$gene2) & grepl("KIAA1549", arriba_df_conf$gene1)]
cbtn_braf <- CBTN_data_maf_primary[which(CBTN_data_maf_primary$Hugo_Symbol == "BRAF"),]
cbtn_braf_v600e_samples <- cbtn_braf$sample_id[which(grepl("V600E", cbtn_braf$HGVSp_Short))]
ICGC_maf <- read.table(file = paste0(datapath, "snv/dkfz_mafKB.maf"),
                        sep = "\t", check.names = F, header = TRUE, comment.char = "",stringsAsFactors = FALSE)
ICGC_maf_nsyn <- ICGC_maf[!ICGC_maf$variant_classification %in% c("splicing", "unknown", "synonymous SNV"),]
colnames(ICGC_maf_nsyn)[colnames(ICGC_maf_nsyn) == "Tumor_Sample_Barcode"] <- "sample_id"
head(ICGC_maf_nsyn)
dkfz_braf <- ICGC_maf_nsyn[which(ICGC_maf_nsyn$Hugo_Symbol == "BRAF"),]
dkfz_braf_v600e_samples <- dkfz_braf$sample_id[which(grepl("V600E", dkfz_braf$HGVSp_Short))]
braf_v600e_samples <- c(dkfz_braf_v600e_samples, cbtn_braf_v600e_samples)
braf_fusion_samples
metadata$tumour_subtype[metadata$sample_id %in% braf_fusion_samples & metadata$cohort == "pedLGG"] <- "BRAF_KIAA1549"
metadata$tumour_subtype[metadata$sample_id %in% braf_v600e_samples & metadata$cohort == "pedLGG"] <- "BRAF_p.V600E"
metadata$tumour_subtype[is.na(metadata$tumour_subtype)& metadata$cohort == "pedLGG"] <- "BRAF_WT"
table(metadata$tumour_subtype)
estimate_manifest_primary_clean <- metadata
save(estimate_manifest_primary_clean,
         file = paste0(datapath, "ESTIMATE/estimate_manifest_primary_clean_final.RData"))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1326778344258315, 'fraction_numerical': 0.014930808448652586, 'mean_word_length': 7.690928270042194, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '280200', 'license': 'Apache-2.0', 'n_tokens_mistral': 3540, 'n_tokens_neox': 3264, 'n_words': 371, 'path': 'notebooks/11_tumour_subgroups.ipynb', 'repo_name': 'pughlab/immunogenomics_pedNST', 'size': '8238'}