Skip to content

Commit

Permalink
allowing NA's in abudance_percent and cumulative percent.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Apr 11, 2023
1 parent 43d871b commit 40607ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/LFQDataSummariser.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ LFQDataSummariser <- R6::R6Class(
dall$data[[i]] <- "ALL"
}
all <- dplyr::bind_rows(dfac$data, dall$data)
nested <- all |> dplyr::group_by(!!rlang::sym(self$lfq$config$table$factor_keys_depth())) |> tidyr::nest()
nested <- all |> dplyr::group_by(!!!rlang::syms(self$lfq$config$table$factor_keys_depth())) |> tidyr::nest()
for (i in seq_len(nrow(nested))) {
nested$data[[i]] <- nested$data[[i]] |>
dplyr::arrange(.data$meanArea) |>
dplyr::mutate(id = dplyr::row_number()) |>
dplyr::mutate(abundance_percent = meanArea/sum(meanArea)*100 ) |>
dplyr::mutate(abundance_percent_cumulative = cumsum(abundance_percent)) |>
dplyr::mutate(abundance_percent = meanArea/sum(meanArea, na.rm = TRUE)*100 ) |>
dplyr::mutate(abundance_percent_cumulative = cumsum(ifelse(is.na(abundance_percent), 0, abundance_percent)) + abundance_percent*0) |>
dplyr::mutate(percent_prot = id / max(id) * 100)
}
res <- tidyr::unnest(nested, cols = "data")
Expand Down

0 comments on commit 40607ae

Please sign in to comment.