Skip to content

Add function to remove rows/columns with all zeros #183

Open
@zachary-foster

Description

@zachary-foster

I started one, but dont have time to polish it before next release. I will put it here for now.

#' @keywords internal
remove_empty_dims <- function(filter_rows = TRUE, filter_cols = FALSE) {
  # Remove rows with all zeros
  if (filter_rows) {
    to_remove <- rowSums(count_table) <= 0
    if (sum(to_remove) > 0) {
      my_print("Removing ", sum(to_remove), ' rows with all zeros:\n  ',
               limited_print(rownames(count_table)[to_remove], type = "silent"))
    }
    count_table <- count_table[! to_remove, ]
  }
  
  # Remove columns with all zeros
  if (filter_cols) {
    to_remove <- colSums(count_table) <= 0
    if (sum(to_remove) > 0) {
      my_print("Removing ", sum(to_remove), ' columns with all zeros:\n  ',
               limited_print(colnames(count_table)[to_remove], type = "silent"))
    }
    count_table <- count_table[, ! to_remove]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions