Skip to content

Commit

Permalink
fix: bug if symbol is NA
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokwee committed Nov 12, 2024
1 parent 0fc8509 commit 1410f5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/pgx-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1478,12 +1478,12 @@ rename_by <- function(counts, annot_table, new_id = "symbol", unique = TRUE) {
# Sum columns of rows with the same gene symbol
if (is.matrix(counts) | is.data.frame(counts)) {
rownames(counts) <- symbol
counts <- counts[!rownames(counts) %in% c("", "NA"), , drop = FALSE]
counts <- counts[!rownames(counts) %in% c("", "NA", NA), , drop = FALSE]
if (unique) counts <- rowmean(counts, rownames(counts))
return(counts)
} else if (is.vector(counts)) {
names(counts) <- symbol
counts <- counts[!names(counts) %in% c("", "NA")]
counts <- counts[!names(counts) %in% c("", "NA", NA)]
if (unique) counts <- tapply(counts, names(counts), mean, na.rm = TRUE)
return(counts)
} else {
Expand Down

0 comments on commit 1410f5e

Please sign in to comment.