Skip to content

Commit

Permalink
fix negative state issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjwilliams1 committed Nov 18, 2024
1 parent b2d12b5 commit 63fbc1d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: signals
Title: Single Cell Genomes with Allele Specificity
Version: 0.11.2
Version: 0.11.3
Author@R: c(person("Marc", "Williams", email = "[email protected]",
role = c("aut", "cre")),
person("Tyler", "Funnell",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# signals 0.11.3

* catch negative state_AS issue for singleton bins

# signals 0.11.2

* fix negative state_AS issue. This was caused during the fill missing step which
Expand Down
14 changes: 11 additions & 3 deletions R/callHSCN.R
Original file line number Diff line number Diff line change
Expand Up @@ -938,12 +938,20 @@ callHaplotypeSpecificCN <- function(CNbins,
dplyr::ungroup() %>%
#catch issue when there is a state transition in the empty bins causing A+B>state
dplyr::mutate(A = ifelse(A + B > state, NA, A),
B = ifelse(is.na(A), NA, B)) %>%
tidyr::fill( c("A", "B"), .direction = "up")
B = ifelse(is.na(A), NA, B)) %>%
dplyr::group_by(chr, cell_id) %>%
tidyr::fill( c("A", "B"), .direction = "up") %>%
dplyr::ungroup() %>%
#sometimes if there is a singleton bin with a different state even the above doesn't catch
#all A + B >state, in this case change the state. This isn't ideal, very hacky
dplyr::mutate(state = ifelse(A + B > state, NA, state),
A = ifelse(is.na(state), NA, B),
B = ifelse(is.na(A), NA, B)) %>%
tidyr::fill( c("state", "A", "B"), .direction = "up")
#add 0|0 states for hom deletions
out[["data"]] <- out[["data"]] %>%
dplyr::mutate(A = ifelse(state == 0, 0, A)) %>%
dplyr::mutate(B = ifelse(state == 0, 0, B))
dplyr::mutate(B = ifelse(state == 0, 0, B))
if (female == FALSE){
#for male patients set A == state and B == 0
out[["data"]] <- out[["data"]] %>%
Expand Down

0 comments on commit 63fbc1d

Please sign in to comment.