diff --git a/NAMESPACE b/NAMESPACE index d32eee9..0fd66ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -98,5 +98,6 @@ export(widen_bins) export(widen_haplotypebins) import(data.table) importFrom(Rcpp,sourceCpp) +importFrom(data.table,":=") importFrom(magrittr,"%>%") useDynLib(signals) diff --git a/R/callHSCN.R b/R/callHSCN.R index f661bcb..10e0f12 100644 --- a/R/callHSCN.R +++ b/R/callHSCN.R @@ -634,6 +634,7 @@ filter_haplotypes <- function(haplotypes, fraction){ #' @param fillmissing For bins with missing counts fill in values based on neighbouring bins #' @param global_phasing_for_diploid When using cluster_per_chr, use all cells for phasing diploid regions within the cluster #' @param chrs_for_global_phasing Which chromosomes to phase using all cells for diploid regions, default is NULL which uses all chromosomes +#' @param female Default is `TRUE`, if set to `FALSE` and patient is "XY", X chromosome states are set to A|0 where A=Hmmcopy state #' #' @return Haplotype specific copy number object #' @@ -691,7 +692,8 @@ callHaplotypeSpecificCN <- function(CNbins, smoothsingletons = TRUE, fillmissing = TRUE, global_phasing_for_balanced = FALSE, - chrs_for_global_phasing = NULL) { + chrs_for_global_phasing = NULL, + female = TRUE) { if (!clustering_method %in% c("copy", "breakpoints")) { stop("Clustering method must be one of copy or breakpoints") } @@ -720,6 +722,17 @@ callHaplotypeSpecificCN <- function(CNbins, haplotypes$chr <- sub("chr", "", haplotypes$chr) } + if (female == TRUE){ + #do not infer states for chr "Y" + haplotypes <- filter(haplotypes, chr != "Y") + CNbins <- filter(CNbins, chr != "Y") + } else{ + #do not infer states for chr "X" or "Y" + haplotypes <- filter(haplotypes, chr != "Y") + haplotypes <- filter(haplotypes, chr != "X") + CNbins <- filter(CNbins, chr != "Y") + } + nhaplotypes <- haplotypes %>% dplyr::group_by(cell_id) %>% dplyr::summarize(n = sum(totalcounts)) %>% @@ -927,6 +940,12 @@ callHaplotypeSpecificCN <- function(CNbins, out[["data"]] <- out[["data"]] %>% dplyr::mutate(A = ifelse(state == 0, 0, A)) %>% dplyr::mutate(B = ifelse(state == 0, 0, B)) + if (female == FALSE){ + #for male patients set A == state and B == 0 + out[["data"]] <- out[["data"]] %>% + dplyr::mutate(A = ifelse(chr == "X", state, A)) %>% + dplyr::mutate(B = ifelse(chr == "X", 0, B)) + } out[["data"]] <- add_states(out[["data"]]) out[["data"]] <- as.data.frame(out[["data"]]) } diff --git a/R/clustering.R b/R/clustering.R index bc9b72e..8d3bd34 100644 --- a/R/clustering.R +++ b/R/clustering.R @@ -92,7 +92,8 @@ umap_clustering <- function(CNbins, ret_model = TRUE, ret_nn = TRUE, pca = pca, - fast_sgd = fast_sgd) + fast_sgd = fast_sgd, + pca_method = "svdr") } ) diff --git a/man/callHaplotypeSpecificCN.Rd b/man/callHaplotypeSpecificCN.Rd index 1e8ac40..e98843a 100644 --- a/man/callHaplotypeSpecificCN.Rd +++ b/man/callHaplotypeSpecificCN.Rd @@ -17,8 +17,8 @@ callHaplotypeSpecificCN( phasebyarm = FALSE, minfrachaplotypes = 0.7, likelihood = "auto", - minbins = 100, - minbinschr = 10, + minbins = 0, + minbinschr = 0, phased_haplotypes = NULL, clustering_method = "copy", maxloherror = 0.035, @@ -31,7 +31,8 @@ callHaplotypeSpecificCN( smoothsingletons = TRUE, fillmissing = TRUE, global_phasing_for_balanced = FALSE, - chrs_for_global_phasing = NULL + chrs_for_global_phasing = NULL, + female = TRUE ) } \arguments{ @@ -85,6 +86,8 @@ callHaplotypeSpecificCN( \item{chrs_for_global_phasing}{Which chromosomes to phase using all cells for diploid regions, default is NULL which uses all chromosomes} +\item{female}{Default is \code{TRUE}, if set to \code{FALSE} and patient is "XY", X chromosome states are set to A|0 where A=Hmmcopy state} + \item{viterbver}{Version of viterbi algorithm to use (cpp or R)} \item{global_phasing_for_diploid}{When using cluster_per_chr, use all cells for phasing diploid regions within the cluster}