From 1cbc480fe6efb035a0ad6cd5ad407403a16935f0 Mon Sep 17 00:00:00 2001 From: marcjwilliams1 Date: Fri, 3 Sep 2021 11:26:41 -0400 Subject: [PATCH] bugfix: specify filtering in ascn --- R/callASCN.R | 5 +++-- R/callHSCN.R | 2 +- man/callAlleleSpecificCN.Rd | 4 +++- man/callHaplotypeSpecificCN.Rd | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/R/callASCN.R b/R/callASCN.R index fff3a57..ede323b 100644 --- a/R/callASCN.R +++ b/R/callASCN.R @@ -177,6 +177,7 @@ switch_alleles <- function(cn) { #' @param minbins Minimum number of bins containing both haplotype counts and copy number data for a cell to be included #' @param minbinschr Minimum number of bins containing both haplotype counts and copy number data per chromosome for a cell to be included #' @param maxloherror Maximum value for LOH error rate +#' @param filterhaplotypes filter out haplotypes present in less than X fraction, default is 0.1 #' #' @return allele specific copy number object which includes dataframe similar to input with additional columns which include #' @@ -204,7 +205,7 @@ callAlleleSpecificCN <- function(CNbins, minbins = 100, minbinschr = 10, maxloherror = 0.03, - filterhaplotypes = TRUE) { + filterhaplotypes = 0.1) { if (!likelihood %in% c("binomial", "betabinomial", "auto")) { stop("Likelihood model for HMM emission model must be one of binomial, betabinomial or auto", @@ -226,7 +227,7 @@ callAlleleSpecificCN <- function(CNbins, } if (filterhaplotypes){ - haplotypes <- filter_haplotypes(haplotypes) + haplotypes <- filter_haplotypes(haplotypes, filterhaplotypes) } CNBAF <- combineBAFCN(haplotypes = haplotypes, CNbins = CNbins) diff --git a/R/callHSCN.R b/R/callHSCN.R index 157a0d0..4b97ac2 100644 --- a/R/callHSCN.R +++ b/R/callHSCN.R @@ -549,7 +549,7 @@ filter_haplotypes <- function(haplotypes, fraction){ haplotypes <- as.data.table(haplotypes) nhaps <- dim(haplotypes)[1] total_cells <- length(unique(haplotypes$cell_id)) - message("Filtering out haplotypes present < 10% of cells...") + message(paste0("Filtering out haplotypes present < ", fraction * 100, "% of cells...")) haplotypes <- haplotypes %>% .[, ncells := length(unique(cell_id)), by = .(chr, start, end, hap_label)] %>% .[, fcells := ncells / total_cells] %>% diff --git a/man/callAlleleSpecificCN.Rd b/man/callAlleleSpecificCN.Rd index 7d7bffb..866cce6 100644 --- a/man/callAlleleSpecificCN.Rd +++ b/man/callAlleleSpecificCN.Rd @@ -17,7 +17,7 @@ callAlleleSpecificCN( minbins = 100, minbinschr = 10, maxloherror = 0.03, - filterhaplotypes = TRUE + filterhaplotypes = 0.1 ) } \arguments{ @@ -44,6 +44,8 @@ callAlleleSpecificCN( \item{minbinschr}{Minimum number of bins containing both haplotype counts and copy number data per chromosome for a cell to be included} \item{maxloherror}{Maximum value for LOH error rate} + +\item{filterhaplotypes}{filter out haplotypes present in less than X fraction, default is 0.1} } \value{ allele specific copy number object which includes dataframe similar to input with additional columns which include diff --git a/man/callHaplotypeSpecificCN.Rd b/man/callHaplotypeSpecificCN.Rd index 57f9449..4028bf1 100644 --- a/man/callHaplotypeSpecificCN.Rd +++ b/man/callHaplotypeSpecificCN.Rd @@ -25,7 +25,7 @@ callHaplotypeSpecificCN( overwritemincells = NULL, cluster_per_chr = TRUE, viterbiver = "cpp", - filterhaplotypes = TRUE + filterhaplotypes = 0.1 ) } \arguments{ @@ -64,6 +64,8 @@ callHaplotypeSpecificCN( \item{overwritemincells}{Overwrite the the number of cells to use for clustering/phasing} \item{cluster_per_chr}{Whether to cluster per chromosome to rephase alleles or not} + +\item{filterhaplotypes}{filter out haplotypes present in less than X fraction, default is 0.1} } \value{ allele specific copy number object which includes dataframe similar to input with additional columns which include