Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Niinleslie committed Jun 11, 2021
1 parent 1059998 commit 3bcc55f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 45 deletions.
2 changes: 1 addition & 1 deletion MesKit.docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
41 changes: 23 additions & 18 deletions R/compareCCF.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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(
Expand All @@ -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){
Expand Down Expand Up @@ -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) )
}

Expand All @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions inst/shiny/dom/ccf.CSV
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions inst/shiny/dom/maf.csv
Original file line number Diff line number Diff line change
@@ -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
19 changes: 13 additions & 6 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
12 changes: 6 additions & 6 deletions inst/shiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand All @@ -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"
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion man/compareCCF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3bcc55f

Please sign in to comment.