Skip to content

Commit

Permalink
remove no content cells and mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
xiayh17 committed Dec 19, 2023
1 parent 8e6719e commit 605f6a1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/CFmatrixParse.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,28 @@ cf2treedata <- function(CFmatrix_file) {

## count mutations
sum_mut=colSums(cf_mat[,-1])
sum_cell=rowSums(cf_mat[,-1])
mut_names=colnames(cf_mat)[-1]

## if there is a column all = 0
## drop it
zero_index=sum_mut==0
zero_mut=mut_names[zero_index]
zero_muts_index=sum_mut==0
zero_mut=mut_names[zero_muts_index]
if (length(zero_mut)>0) {
warning(c(paste0(zero_mut,collapse = ",")," Not be contained in any cell. Removed!"))
}

## if there is a row all = 0
## drop it
zero_cells_index=sum_cell==0
if (sum(zero_cells_index)>0) {
warning(c(length(zero_cells_index)," Cells Not contain any mutation. Removed!"))
}

## remove
cf_mat=cf_mat[!zero_cells_index,mut_names[!zero_muts_index]]


## if there is a column all = 1
## set as root
all_mut_index=sum_mut==nrow(cf_mat)
Expand Down

0 comments on commit 605f6a1

Please sign in to comment.