Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,5 @@

* Fix `average_batch_r2` and `flowsom_mapping_similarity` writing `metric_ids` and `metric_values`
as scalars instead of lists, as required by `file_score.yaml` (PR #130).

* Clean up stale mock parameters and dead code (PR #133).
2 changes: 1 addition & 1 deletion _viash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ description: |
references: {}

info:
image: The name of the image file to use for the component on the website.
image: thumbnail.svg
test_resources:
- type: s3
path: s3://openproblems-data/resources_test/task_cyto_batch_integration/
Expand Down
10 changes: 7 additions & 3 deletions src/control_methods/shuffle_integration_within_batch/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

## VIASH START
par = {
"input_unintegrated": "resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/unintegrated_censored.h5ad",
"output": "output.h5ad",
"input_unintegrated": "resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/unintegrated.h5ad",
"output_integrated_split1": "resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/control_integrated_split1.h5ad",
"output_integrated_split2": "resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/control_integrated_split2.h5ad",
}
meta = {
"name": "shuffle_integration_within_batch",
"resources_dir": "src/control_methods",
}
meta = {"name": "shuffle_integration_within_batch"}
## VIASH END

print("Importing helper functions", flush=True)
Expand Down
2 changes: 1 addition & 1 deletion src/data_processors/process_dataset/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'input': 'resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/common_dataset.h5ad',
'output_censored_split1': 'resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/censored_split1.h5ad',
'output_censored_split2': 'resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/censored_split2.h5ad',
'output_validation': 'resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/validation.h5ad'
'output_unintegrated': 'resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/unintegrated.h5ad'
}
meta = {
'resources_dir': 'target/executable/data_processors/process_dataset',
Expand Down
7 changes: 4 additions & 3 deletions src/methods/gaussnorm/script.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ library(flowStats)

## VIASH START
par <- list(
input = "resources_test/task_cyto_batch_integration/cyto_spleen_subset/unintegrated_censored.h5ad",
input = "resources_test/task_cyto_batch_integration/mouse_spleen_flow_cytometry_subset/censored_split1.h5ad",
output = "output.h5ad"
)
meta <- list(
name = "gaussNorm",
temp_dir: '/tmp'
name = "gaussnorm",
temp_dir = "/tmp",
resources_dir = "src/utils"
)
## VIASH END

Expand Down
7 changes: 2 additions & 5 deletions src/metrics/average_batch_r2/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
## VIASH END

sys.path.append(meta["resources_dir"])
from helper import batch_r2, concat_paired_samples, fit_r2
from helper import batch_r2
from helper_functions import (
get_obs_var_for_integrated,
remove_unlabelled,
Expand All @@ -40,10 +40,7 @@
integrated_s2 = subset_nocontrols(integrated_s2)
integrated_s2 = subset_markers_tocorrect(integrated_s2)

print(
integrated_s1.obs, integrated_s2.obs, flush=True
) ### Debugging line, can be removed later
print("Computing average_batch_r2 global", flush=True)
print("Computing average_batch_r2 per cell type", flush=True)

donor_list = integrated_s1.obs["donor"].unique()

Expand Down
40 changes: 0 additions & 40 deletions src/utils/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,43 +150,3 @@ remove_unlabelled <- function(adata) {
c("unlabelled", "unlabeled")
adata[!is_unlabelled, ]
}

#' Subsets the anndata object in a stratified manner
#' with 'cell type' and 'sample' as strata.
#'
#' @param adata AnnData object
#' @param frac numeric, fraction of cells to keep for each cell type
#' @param seed numeric, seed for reproducibility
#' @param anndatar logical, whether the input is anndataR object or not
#' @return AnnData object with only the markers to correct
subset_by_celltype <- function(adata, frac = 0.5, seed = 1, anndatar = TRUE) {
set.seed(seed)

obs <- adata$obs
obs$cell_id <- rownames(obs)
obs$.row <- seq_len(nrow(obs)) # original order

keep_ids <- obs %>%
group_by(cell_type, sample) %>%
slice_sample(prop = frac) %>%
ungroup() %>%
arrange(.row) %>% # restore original order
pull(cell_id)

if (anndatar == TRUE){
keep_idx <- match(keep_ids, adata$obs_names)

adata_sub <- anndataR::AnnData(
X = NULL,
obs = adata$obs[keep_idx, , drop = FALSE],
var = adata$var,
uns = adata$uns,
layers = list(
"integrated" = adata$layers$integrated[keep_idx, , drop = FALSE]
)
)
} else{
adata_sub <- adata[keep_ids, ]
}
}

Loading