Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address metadata during altexp merging and other metadata fixes #255

Merged
merged 22 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b8884e4
Remove previous metadata testing
sjspielman Dec 21, 2023
a7185b4
metadata handling overhaul to avoid duplicated code and improved checks
sjspielman Dec 21, 2023
77074d6
metadata function docs and a little reorg so they are all in the same…
sjspielman Dec 21, 2023
a46437c
Add tests for new functions, and modify a buggy part accordingly
sjspielman Dec 21, 2023
39e0854
use c() instead
sjspielman Dec 21, 2023
f35ed2f
add tests for altexp metadata for the condition when one altexp isn't…
sjspielman Dec 21, 2023
ee24fae
Merge sjspielman/150-next-steps and address conflict
sjspielman Dec 21, 2023
11e693e
Merge branch 'main' into sjspielman/250-merge-metadata
sjspielman Dec 21, 2023
64f3b8a
Apply suggestions from code review
sjspielman Dec 22, 2023
44b46fc
Don't transpose at all, use pluck instead. Update docs, and add to WO…
sjspielman Dec 22, 2023
9aea1e9
More plucking for library_metadata, and fix sample_metadata df constr…
sjspielman Dec 22, 2023
c237355
apparently transpose has been superceded by list_transpose
sjspielman Dec 22, 2023
ef6629a
Updated metadata tests
sjspielman Dec 22, 2023
c26d826
ensure correct metadata order for altexp metadata
sjspielman Dec 22, 2023
cf9a5d4
Apply suggestions from code review
sjspielman Dec 22, 2023
24e97b1
use has_altexp_name vector with keep and discard
sjspielman Dec 22, 2023
3598c94
Add metadata test for sample_metadata
sjspielman Dec 22, 2023
08351d8
dear pluck, you are now gone but not forgotten
sjspielman Dec 22, 2023
020b9bf
Merge branch 'main' into sjspielman/250-merge-metadata
jashapiro Dec 22, 2023
8ee0594
Update R/merge_sce_list.R
sjspielman Dec 22, 2023
f7b8037
Apply suggestions from code review
sjspielman Dec 22, 2023
6599cfc
Update R/merge_sce_list.R
jashapiro Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions R/merge_sce_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,26 @@ get_altexp_attributes <- function(sce_list) {
#' - `sample_metadata`: a data frame with all distinct rows from the pre-merge sample_metadata data frames,
#' with all values coerced to character
#'
#' @param metadata_list List of metadata to update
#' @param metadata_list List of metadata to update, named by SCE
#'
#' @return Updated metadata list to include in the merged SCE
prepare_merged_metadata <- function(metadata_list) {
metadata_list <- metadata_list |>
purrr::transpose()
# Check names
if (is.null(names(metadata_list))) {
stop("Cannot prepare merged metadata; list is unnamed.")
}

metadata_library_ids <- names(metadata_list) |>
purrr::map_chr(
\(sce_metadata) purrr::pluck(metadata_list[[sce_metadata]], "library_id")
)

metadata_sample_ids <- names(metadata_list) |>
purrr::map_chr(
\(sce_metadata) purrr::pluck(metadata_list[[sce_metadata]], "sample_id")
)



# first check that this library hasn't already been merged
if ("library_metadata" %in% names(metadata_list)) {
Expand All @@ -424,15 +438,6 @@ prepare_merged_metadata <- function(metadata_list) {
))
}

# Flatten each list of library ids and sample ids into vectors
metadata_library_ids <- purrr::list_c(metadata_list$library_id,
ptype = "character"
)

metadata_sample_ids <- purrr::list_c(metadata_list$sample_id,
ptype = "character"
)

# combine into final metadata list
final_metadata_list <- list(
# vector of all library ids
Expand Down Expand Up @@ -471,8 +476,8 @@ prepare_merged_metadata <- function(metadata_list) {
#' Helper function to check that expected metadata fields are present in a given
#' list of SCEs.
#'
#' The fields `library_id` and `sample_id` must be present. If either is missig from
#' any SCE, an error is thrown.
#' The fields `library_id` and `sample_id` must be present. If either is missing from
sjspielman marked this conversation as resolved.
Show resolved Hide resolved
#' any SCE, an error is thrown. This function does not return anything.
#'
#' @param sce_list List of SCEs to check
#' @param expected_fields a vector of metadata fields that should be present
Expand Down
3 changes: 3 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
altExp
commenter
pre
SCE
SCEs
scpcaTools
tidyverse
18 changes: 18 additions & 0 deletions man/check_metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions man/extract_metadata_for_altexp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/prepare_merged_metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions man/update_sce_metadata.Rd

This file was deleted.

Loading