From 3bcc55fe66587bdc75727b8b083898e8e35b9809 Mon Sep 17 00:00:00 2001 From: Niinleslie <705172894@qq.com> Date: Fri, 11 Jun 2021 16:57:18 +0800 Subject: [PATCH] #248 --- MesKit.docker.md | 2 +- R/compareCCF.R | 41 +++++++++++++++++++++++------------------ inst/shiny/dom/ccf.CSV | 10 ++++------ inst/shiny/dom/maf.csv | 13 ++++++------- inst/shiny/server.R | 19 +++++++++++++------ inst/shiny/ui.R | 12 ++++++------ man/compareCCF.Rd | 1 - 7 files changed, 53 insertions(+), 45 deletions(-) diff --git a/MesKit.docker.md b/MesKit.docker.md index b1edf004..ddb2692b 100644 --- a/MesKit.docker.md +++ b/MesKit.docker.md @@ -23,7 +23,7 @@ $ docker pull niinleslie/mesKit After pulling MesKit image checked by `docker images`, you should run the `docker run` command below to initiate the docker container and make sure that the port is suitable for shiny-server's configuration: ```shell -$ docker run -p 3838:3838 niinleslie/MesKit shiny-server +$ docker run -p 3838:3838 niinleslie/meskit shiny-server ``` If the command was workable, the docker container would start running and the shiny server of MesKit would be deployed. To , you could see the following messages: diff --git a/R/compareCCF.R b/R/compareCCF.R index b5c0796b..05160752 100644 --- a/R/compareCCF.R +++ b/R/compareCCF.R @@ -1,6 +1,5 @@ #' @title compareCCF #' @description Compare the CCF between samples/tumor pairs -#' This function requires CCF for clustering #' @param maf Maf or MafList object generated by \code{\link{readMaf}} function. #' @param patient.id Select the specific patients. Default NULL, all patients are included. #' @param min.ccf The minimum value of CCF. Default 0. @@ -27,8 +26,18 @@ compareCCF <- function(maf, ...){ - processComCCF <- function(m, pairByTumor){ - maf_data <- getMafData(m) %>% + processComCCF <- function(patient, pairByTumor, maf_input){ + + maf <- maf_input[[patient]] + + maf_data <- getMafData(maf) + ## check if ccf data is provided + if(! "CCF" %in% colnames(maf_data)){ + stop(paste0("compareCCF function requires CCF data.\n", + "No CCF data was found when generate Maf/MafList object.")) + } + + maf_data <- maf_data %>% tidyr::unite( "Mut_ID", c( @@ -41,19 +50,12 @@ compareCCF <- function(maf, remove = FALSE ) %>% dplyr::filter(!is.na(.data$CCF)) - - patient <- getMafPatient(m) + if(nrow(maf_data) == 0){ message("Warning: there was no mutation in ", patient, " after filtering.") return(NA) } - - ## check if ccf data is provided - if(! "CCF" %in% colnames(maf_data)){ - stop(paste0("ccfDensity function requires CCF data.\n", - "No CCF data was found when generate Maf/MafList object.")) - } if(pairByTumor){ types <- unique(maf_data$Tumor_ID) if(length(types) < 2){ @@ -92,22 +94,22 @@ compareCCF <- function(maf, sep = ":", remove = FALSE) %>% dplyr::distinct(.data$Mut_ID2, .keep_all = TRUE) %>% dplyr::select("Tumor_ID", "Hugo_Symbol", "Mut_ID", "CCF") %>% - tidyr::pivot_wider(names_from = "Tumor_ID", values_from = "CCF") %>% + tidyr::pivot_wider(names_from = "Tumor_ID", values_from = "CCF") # dplyr::select("Tumor_ID", "Hugo_Symbol", "Mut_ID", "CCF") %>% # tidyr::pivot_wider(names_from = "Tumor_ID", values_from = c("CCF", "Clonal_Status")) %>% - tidyr::drop_na() - + # tidyr::drop_na() }else{ ccf.pair <- maf_data %>% dplyr::filter(.data$Tumor_Sample_Barcode %in% c(S1, S2)) %>% dplyr::select("Tumor_Sample_Barcode", "Hugo_Symbol", "Mut_ID", "CCF") %>% - tidyr::pivot_wider(names_from = "Tumor_Sample_Barcode", values_from = "CCF") %>% - tidyr::drop_na() + tidyr::pivot_wider(names_from = "Tumor_Sample_Barcode", values_from = "CCF") + # tidyr::drop_na() } if(nrow(ccf.pair) == 0){ message(paste0("Warning: no shared mutaions were detected between ",S1, " and ", S2) ) return(NA) } + ccf.pair[is.na(ccf.pair)] <- 0 return(as.data.frame(ccf.pair) ) } @@ -127,8 +129,11 @@ compareCCF <- function(maf, mafObj = TRUE, ...) - result <- lapply(maf_input, processComCCF, pairByTumor) - result <- result[!is.na(result)] + patient_list <- names(maf_input) + result <- lapply(patient_list, processComCCF, pairByTumor, maf_input) + patient_list <- patient_list[!is.na(result)] + result <- result[!is.na(result)] + names(result) <- patient_list if(length(result) == 0){ return(NA) diff --git a/inst/shiny/dom/ccf.CSV b/inst/shiny/dom/ccf.CSV index f3d86de3..2b61f236 100644 --- a/inst/shiny/dom/ccf.CSV +++ b/inst/shiny/dom/ccf.CSV @@ -1,7 +1,5 @@ Patient_ID,Tumor_Sample_Barcode,Chromosome,Start_Position,CCF,CCF_Std -HCC5647,T4,22,43190575,0.61129925572972,0.197135560586529 -HCC5647,T5,22,43190575,0.623955553137915,0.195239969257916 -HCC5647,T3,22,43190575,0.512141355057113,0.177512751910576 -HCC5647,T1,22,43190575,0.689192384588648,0.216222535384305 -HCC5647,T4,5,178224614,0.766880555852247,0.0908572162242958 -HCC5647,T5,5,178224614,0.776092750482125,0.0864071222943562 +V402,V402_P_1,1,899515,0.031,0.126 +V402,V402_P_2,1,899515,0.18,0.335 +V402,V402_P_3,1,899515,0.068,0.224 +V402,V402_P_4,1,899515,0,0.107 diff --git a/inst/shiny/dom/maf.csv b/inst/shiny/dom/maf.csv index 993affe5..ae50a1c6 100644 --- a/inst/shiny/dom/maf.csv +++ b/inst/shiny/dom/maf.csv @@ -1,7 +1,6 @@ -Hugo_Symbol,Chromosome,Start_Position,End_Position,Variant_Classification,Variant_Type,Reference_Allele,Tumor_Seq_Allele2,Ref_allele_depth,Alt_allele_depth,VAF,Tumor_Sample_Barcode,Patient_ID,Tumor_ID -CFAP74,1,1880545,1880545,Intron,SNP,C,A,16,3,0.1578,T1,HCC5647,Primary -CFAP74,1,1880550,1880550,Intron,SNP,T,C,18,3,0.1428,T1,HCC5647,Primary -CFAP74,1,1887387,1887387,Intron,SNP,T,A,15,8,0.3478,T1,HCC5647,Primary -PRKCZ,1,1991054,1991054,Intron,SNP,C,T,138,27,0.1636,T1,HCC5647,Primary -NPHP4,1,5965283,5965283,Intron,SNP,T,A,26,12,0.3157,T1,HCC5647,Primary -CHD5,1,6202450,6202450,Intron,SNP,T,A,143,25,0.1488,T1,HCC5647,Primary +Hugo_Symbol,Chromosome,Start_Position,End_Position,Variant_Classification,Variant_Type,Reference_Allele,Tumor_Seq_Allele2,Ref_allele_depth,Alt_allele_depth,VAF,Tumor_Sample_Barcode +KLHL17,1,899515,899515,Silent,SNP,C,T,85,1,0.012,V402_P_1 +AGRN,1,982996,982996,Missense_Mutation,SNP,G,A,97,1,0.01,V402_P_1 +PANK4,1,2452742,2452742,Nonsense_Mutation,SNP,C,A,80,5,0.059,V402_P_1 +CHD5,1,6203883,6203883,Missense_Mutation,SNP,G,C,20,5,0.2,V402_P_1 +MASP2,1,11106655,11106655,Missense_Mutation,SNP,C,T,21,1,0.045,V402_P_1 diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 9b470e09..5b75d2c3 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -97,10 +97,7 @@ shinyServer(function(input, output, session){ their annotations. The following fields are highly recommended to be contained in the MAF files.", style = "font-size:16px; font-weight:500;line-height:30px;"), - p(strong("Mandatory fields"),": Hugo_Symbol, Chromosome, Start_Position, End_Position, - Variant_Classification, Variant_Type, Reference_Allele, - Tumor_Seq_Allele2, Ref_allele_depth, Alt_allele_depth, - VAF, Tumor_Sample_Barcode, Patient_ID, Tumor_ID", + p(strong("Mandatory fields"),": Hugo_Symbol, Chromosome, Start_Position, End_Position, Variant_Classification, Variant_Type, Reference_Allele, Tumor_Seq_Allele2, Ref_allele_depth, Alt_allele_depth, VAF, Tumor_Sample_Barcode", style = "font-size:16px; font-weight:500;line-height:30px;"), h3(strong("Example MAF file")) ), @@ -139,7 +136,7 @@ shinyServer(function(input, output, session){ h3(strong("The CCF file")), p("CCF files contain cancer cell fraction of each mutation.", style = "font-size:16px; font-weight:500;line-height:30px;"), - p(strong("Mandatory fields"),": Patient_ID, Tumor_Sample_Barcode, Chromosome, Start_Position, CCF, CCF_std/CCF_CI_High (required when identify clonal/subclonal mutations)", + p(strong("Mandatory fields"),": Patient_ID, Tumor_Sample_Barcode, Chromosome, Start_Position, CCF and CCF_Std/CCF_CI_High (required when identifying clonal/subclonal mutations)", style = "font-size:16px; font-weight:500;line-height:30px;"), h3(strong("Example CCF file:")), DT::dataTableOutput("ied2"), @@ -1145,6 +1142,7 @@ shinyServer(function(input, output, session){ show.geneList <- input$mutheatmap_showgenelist gene.text.size <- as.numeric(input$mutheatmap_genetextsize) } + pdf(NULL) hm <- mutHeatmap(maf, patient.id = input$mutheatmap_patientid, geneList = genelist, @@ -1690,7 +1688,16 @@ shinyServer(function(input, output, session){ h3(strong("The segment file")), p("The segment file store information about copy number of each segment.", style = "font-size:16px; font-weight:500;line-height:30px;"), - p(strong("Mandatory fields"),": Patient_ID, Tumor_Sample_Barcode, Chromosome, Start_Position, End_Position, CopyNumber, Tumor_Sample_Label(optional)", + p(strong("Mandatory fields"), + ": Patient_ID, + Tumor_Sample_Barcode, + Chromosome, + Start_Position, + End_Position, + SegmentMean/CopyNumber, + Minor_CN(optional), + Major_CN(optional), + Tumor_Sample_Label(optional)", style = "font-size:16px; font-weight:500;line-height:30px;"), h3(strong("Example segment file:")), DT::dataTableOutput("ied_seg"), diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 1e1dc33a..89f20d29 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -31,7 +31,7 @@ bodyHome <- tabItem("home", status = "info", solidHeader = TRUE, title = div(strong("Introduction"),style = "font-size:2em; font-weight:500;"), - p("Cancer develops as a result of the accumulation of genetic aberrations, which promotes the generation of distinct subpopulations of tumor cells and shapes intra-tumor heterogeneity (ITH). ITH is involves in tumor growth, progression, invasion, and metastasis, presenting one of the most significant barriers to accurate diagnoses and effective treatments of cancers. Therefore, dissecting and interpreting ITH of tumor dynamics is one of the major tasks in cancer research. Here, we present MesKit, an R-based package, to provide commonly used analysis and visualization modules in MRS study.", + p("Cancer develops as a result of the accumulation of genetic aberrations, which promotes the generation of distinct subpopulations of tumor cells and shapes intra-tumor heterogeneity (ITH). ITH is involves in tumor growth, progression, invasion, and metastasis, presenting one of the most significant barriers to accurate diagnoses and effective treatments of cancers. Therefore, dissecting and interpreting ITH of tumor dynamics is one of the major tasks in cancer research. Here, we present MesKit, an R/Bioconductor package that provides commonly used analysis and visualization modules for MRS studies.", style = "font-size:18px; font-weight:500;line-height:40px;"), br() ) @@ -57,10 +57,10 @@ bodyHome <- tabItem("home", br(), br(), h3(strong("With this MesKit Shiny APP:")), - p("- Characterize mutational landscape",br(), + p("- Visualize mutational landscape",br(), "- Quantify heterogeneity within or between tumors from the same patient",br(), "- Infer metastatic routes",br(), - "- Perform mutational signature analysis on different levels",br(), + "- Perform mutational signature analysis at different levels ",br(), "- Construct and visualize phylogenetic trees", style = "font-size:18px; font-weight:500;line-height:50px;"), style = "text-align: left;float:left;padding-left:0px;margin:0px" @@ -702,7 +702,7 @@ bodyITH <- tabItem("ITH", uiOutput("msdb") ), tabPanel( - title = div(icon("image"), "Mut clustering", style = "font-size:1.5em; font-weight:600; "), + title = div(icon("image"), "Cluster mutations", style = "font-size:1.5em; font-weight:600; "), value = "ith_vafcluster", uiOutput("vafcluster.patientlist"), uiOutput("vafcluster_table_ui"), @@ -1878,7 +1878,7 @@ bodytree <- tabItem('tree', uiOutput("phylotree_downloadbutton_ui") ), tabPanel( - title = div(icon("tree"), "Compare tree", style = "font-size:1.5em; font-weight:600; "), + title = div(icon("tree"), "Compare trees", style = "font-size:1.5em; font-weight:600; "), value = 'S_comparetree', verbatimTextOutput("comparetree_dist"), br(), @@ -1899,7 +1899,7 @@ bodytree <- tabItem('tree', # uiOutput('treemutsig_table_ui') ), tabPanel( - title = div(icon("image"), "MutTrunkBranch", style = "font-size:1.5em; font-weight:600; "), + title = div(icon("image"), "Trunk vs Branch", style = "font-size:1.5em; font-weight:600; "), value = 'S_muttrunkbranch', uiOutput("muttrunkbranch.patientlist"), br(), diff --git a/man/compareCCF.Rd b/man/compareCCF.Rd index 2278c1cb..2167a720 100644 --- a/man/compareCCF.Rd +++ b/man/compareCCF.Rd @@ -32,7 +32,6 @@ a result list of CCF comparing between samples/tumor pairs } \description{ Compare the CCF between samples/tumor pairs -This function requires CCF for clustering } \examples{ maf.File <- system.file("extdata/", "CRC_HZ.maf", package = "MesKit")