Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolved #293 #375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions R/Waterfall-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ setClass("Waterfall",
#' @param recurrence Numeric value between 0 and 1 specifying a
#' mutation recurrence cutoff. Genes which do not have mutations in the
#' proportion of samples defined are removed.
#' @param markMutationOverlap Boolean specifying whether multiple mutations in the same
#' gene/sample should be denoted by an asterisks. False by default.
#' @param genes Character vector specifying genes to keep, if not "NULL" all genes not specified
#' are removed. Further genes specified but not present in the data will be added.
#' @param geneOrder Character vector specifying the order in which to plot
Expand Down Expand Up @@ -137,7 +139,7 @@ setClass("Waterfall",
#' @export
Waterfall <- function(input, labelColumn=NULL, samples=NULL, coverage=NULL,
mutation=NULL, genes=NULL, mutationHierarchy=NULL,
recurrence=NULL, geneOrder=NULL, geneMax=NULL,
recurrence=NULL, markMutationOverlap=FALSE, geneOrder=NULL, geneMax=NULL,
sampleOrder=NULL, plotA=c("frequency", "burden", NULL),
plotATally=c("simple", "complex"), plotALayers=NULL,
plotB=c("proportion", "frequency", NULL),
Expand All @@ -151,8 +153,9 @@ Waterfall <- function(input, labelColumn=NULL, samples=NULL, coverage=NULL,
# calculate all data for plots
data <- WaterfallData(input, labelColumn=labelColumn, mutationHierarchy=mutationHierarchy,
samples=samples, coverage=coverage, mutation=mutation, genes=genes,
recurrence=recurrence, geneOrder=geneOrder, geneMax=geneMax,
sampleOrder=sampleOrder, verbose=verbose)
recurrence=recurrence, markMutationOverlap=markMutationOverlap,
geneOrder=geneOrder, geneMax=geneMax, sampleOrder=sampleOrder,
verbose=verbose)

# get the clinical data
if(is.null(clinical)){
Expand Down Expand Up @@ -219,7 +222,7 @@ setClass("WaterfallData",
#' @param object Object of class MutationAnnotationFormat
#' @noRd
WaterfallData <- function(object, labelColumn, samples, mutationHierarchy,
coverage, mutation, genes, recurrence, geneOrder,
coverage, mutation, genes, recurrence, markMutationOverlap, geneOrder,
geneMax, sampleOrder, verbose){

# assign the mapping of mutations and colors
Expand All @@ -230,7 +233,7 @@ WaterfallData <- function(object, labelColumn, samples, mutationHierarchy,

# subset samples if specified
primaryData <- sampSubset(primaryData, samples, verbose)

# calculate the frequency and mutation burden
simpleMutationCounts <- calcSimpleMutationBurden(primaryData, coverage, verbose)
complexMutationCounts <- calcComplexMutationBurden(primaryData, coverage, verbose)
Expand All @@ -240,7 +243,8 @@ WaterfallData <- function(object, labelColumn, samples, mutationHierarchy,

# remove entries for the same gene/sample based on a hierarchy leaving one
# (must happen before recurrenceSubset)
primaryData <- mutHierarchySubset(primaryData, mutationHierarchy, verbose)
primaryData <- mutHierarchySubset(primaryData, mutationHierarchy, markMutationOverlap, verbose)


# Get genes which should be kept based on genes param
keepGenes_a <- geneSubset(primaryData, genes, verbose)
Expand Down Expand Up @@ -1021,12 +1025,17 @@ setMethod(f="geneSubset",
#' @noRd
setMethod(f="mutHierarchySubset",
signature="data.table",
definition=function(object, mutationHierarchy, verbose, ...){
definition=function(object, mutationHierarchy, markMutationOverlap, verbose, ...){

# grab the data
primaryData <- object
rowsPrimaryData <- nrow(primaryData)
mutationHierarchy
if(markMutationOverlap){
counts <- primaryData[,.N,by=.(sample, gene)]
primaryData <- merge(counts, primaryData)
primaryData[,label := N]
primaryData[,N := NULL]
}

# refactor the data frame
primaryData$mutation<- factor(primaryData$mutation, levels=mutationHierarchy$mutation)
Expand Down