From 91942ed65ef8f0b884de847da01bdb1c8ef73101 Mon Sep 17 00:00:00 2001 From: marcjwilliams1 Date: Tue, 24 Aug 2021 05:21:00 -0400 Subject: [PATCH] Add utility function for filtering cells) --- NAMESPACE | 1 + R/util.R | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index dae2e1c..8bcc629 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,6 +25,7 @@ export(createSNVmatrix) export(create_cntransitions) export(create_segments) export(createbreakpointmatrix) +export(filterbycells) export(filtercn) export(fix_assignments) export(fixjitter) diff --git a/R/util.R b/R/util.R index 535f394..84eac1a 100644 --- a/R/util.R +++ b/R/util.R @@ -963,10 +963,10 @@ BAFdistance <- function(cn) { filtercn <- function(cn, average_distance_filt = 0.1, ploidy_filt = NULL, - totalcounts_filt = 0, + totalhapcounts_filt = 0, nsegments_filt = 0){ - qcnew <- dplyr::filter(cn$qc_per_cell, average_distance >= average_distance_filt, - totalcounts >= totalcounts_filt, + qcnew <- dplyr::filter(cn$qc_per_cell, average_distance <= average_distance_filt, + totalhapcounts >= totalhapcounts_filt, nsegments >= nsegments_filt) if (!is.null(ploidy_filt)){ qcnew <- dplyr::filter(qcnew, ploidy == ploidy_filt) @@ -980,3 +980,14 @@ filtercn <- function(cn, return(cn) } + +#' @export +filterbycells <- function(cn, cells){ + cn$data <- cn$data %>% + dplyr::filter(cell_id %in% cells) + cn$qc_per_cell <- cn$qc_per_cell %>% + dplyr::filter(cell_id %in% cells) + cn$qc_summary <- qc_summary(cn) + + return(cn) +}