Skip to content

Aggregating functions and NAs #33

@TuomasBorman

Description

@TuomasBorman

Hi,

Functions like mean(), sum(), and others typically include an na.rm parameter, which allows you to control whether NA values should be excluded from calculations. However, it appears that aggregation functions in scuttle do not provide an option for excluding NA values. While one could convert NA values to 0, this approach is not appropriate for calculating the mean.

Could an na.rm option be added to handle this case?


library(scuttle)
sce <- mockSCE()[1:5, 1:2]
ids <- c("A", "B", "A", "C", "D")
assay(sce)[1, ] <- NA
sumCountsAcrossFeatures(assay(sce), ids)
  Cell_001 Cell_002
A       NA       NA
B      111       98
C      260      233
D       64       70
summarizeAssayByGroup(sce, c("A", "A")) |> assay()
              A
Gene_0001    NA
Gene_0002 104.5
Gene_0003   5.0
Gene_0004 246.5
Gene_0005  67.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions