Skip to content

Commit

Permalink
Option for male/femal
Browse files Browse the repository at this point in the history
  • Loading branch information
Williams committed Oct 1, 2024
1 parent 0cd6d2d commit 3fe9609
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ export(widen_bins)
export(widen_haplotypebins)
import(data.table)
importFrom(Rcpp,sourceCpp)
importFrom(data.table,":=")
importFrom(magrittr,"%>%")
useDynLib(signals)
21 changes: 20 additions & 1 deletion R/callHSCN.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)) %>%
Expand Down Expand Up @@ -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"]])
}
Expand Down
3 changes: 2 additions & 1 deletion R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
)

Expand Down
9 changes: 6 additions & 3 deletions man/callHaplotypeSpecificCN.Rd

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

0 comments on commit 3fe9609

Please sign in to comment.