Skip to content

Commit 40607ae

Browse files
committed
allowing NA's in abudance_percent and cumulative percent.
1 parent 43d871b commit 40607ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/LFQDataSummariser.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ LFQDataSummariser <- R6::R6Class(
122122
dall$data[[i]] <- "ALL"
123123
}
124124
all <- dplyr::bind_rows(dfac$data, dall$data)
125-
nested <- all |> dplyr::group_by(!!rlang::sym(self$lfq$config$table$factor_keys_depth())) |> tidyr::nest()
125+
nested <- all |> dplyr::group_by(!!!rlang::syms(self$lfq$config$table$factor_keys_depth())) |> tidyr::nest()
126126
for (i in seq_len(nrow(nested))) {
127127
nested$data[[i]] <- nested$data[[i]] |>
128128
dplyr::arrange(.data$meanArea) |>
129129
dplyr::mutate(id = dplyr::row_number()) |>
130-
dplyr::mutate(abundance_percent = meanArea/sum(meanArea)*100 ) |>
131-
dplyr::mutate(abundance_percent_cumulative = cumsum(abundance_percent)) |>
130+
dplyr::mutate(abundance_percent = meanArea/sum(meanArea, na.rm = TRUE)*100 ) |>
131+
dplyr::mutate(abundance_percent_cumulative = cumsum(ifelse(is.na(abundance_percent), 0, abundance_percent)) + abundance_percent*0) |>
132132
dplyr::mutate(percent_prot = id / max(id) * 100)
133133
}
134134
res <- tidyr::unnest(nested, cols = "data")

0 commit comments

Comments
 (0)