Skip to content

Commit

Permalink
bugfix: specify filtering in ascn
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjwilliams1 committed Sep 3, 2021
1 parent 331d5ed commit 1cbc480
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions R/callASCN.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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",
Expand All @@ -226,7 +227,7 @@ callAlleleSpecificCN <- function(CNbins,
}

if (filterhaplotypes){
haplotypes <- filter_haplotypes(haplotypes)
haplotypes <- filter_haplotypes(haplotypes, filterhaplotypes)
}

CNBAF <- combineBAFCN(haplotypes = haplotypes, CNbins = CNbins)
Expand Down
2 changes: 1 addition & 1 deletion R/callHSCN.R
Original file line number Diff line number Diff line change
Expand Up @@ -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] %>%
Expand Down
4 changes: 3 additions & 1 deletion man/callAlleleSpecificCN.Rd

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

4 changes: 3 additions & 1 deletion man/callHaplotypeSpecificCN.Rd

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

0 comments on commit 1cbc480

Please sign in to comment.