generated from openproblems-bio/task_template
-
Notifications
You must be signed in to change notification settings - Fork 12
Add CiLISI as new metric component #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
29176c9
add metric: CiLISI
JGarnica22 15e142e
Merge remote-tracking branch 'upstream/main'
JGarnica22 36b1a74
udpate change log
JGarnica22 5e86f8d
fix: move clisi comment below the kBET note to avoid having 2 new fun…
JGarnica22 f3fa1db
fix: remove boilerplate comments for better readability
JGarnica22 c451f46
Update base_r container
JGarnica22 1359498
fix: standardize R identing
JGarnica22 e84b6e7
Merge remote-tracking branch 'upstream/main' into cilisi
JGarnica22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
__merge__: ../../api/comp_metric.yaml | ||
name: cilisi | ||
info: | ||
metrics: | ||
- name: cilisi | ||
label: CiLISI | ||
summary: Cell-type aware version of iLISI (Local inverse Simpson's Index). | ||
iLISI is computed separately for each cell type or cluster, normalized between 0 and 1, and averaged across all cells (global mean). | ||
By default, CiLISI is calculated only for groups with at least 10 cells and 2 distinct batch labels (configurable). | ||
description: | | ||
ciLISI measures batch mixing in a cell type-aware manner by computing iLISI within each cell type and normalizing | ||
the scores between 0 and 1. Unlike iLISI, ciLISI preserves sensitivity to biological variance and avoids favoring | ||
overcorrected datasets with removed cell type signals. | ||
references: | ||
doi: 10.1038/s41467-024-45240-z | ||
links: | ||
documentation: https://github.com/carmonalab/scIntegrationMetrics | ||
repository: https://github.com/carmonalab/scIntegrationMetrics | ||
min: 0 | ||
max: 1 | ||
maximize: true | ||
|
||
- name: cilisi_means | ||
label: CiLISI_means | ||
summary: As CiLISI, but returns mean of per-group CiLISI values (i.e., average of the means per group). instead of a global average. | ||
description: | | ||
ciLISI measures batch mixing in a cell type-aware manner by computing iLISI within each cell type and normalizing | ||
the scores between 0 and 1. Unlike iLISI, ciLISI preserves sensitivity to biological variance and avoids favoring | ||
overcorrected datasets with removed cell type signals. | ||
references: | ||
doi: 10.1038/s41467-024-45240-z | ||
links: | ||
documentation: https://github.com/carmonalab/scIntegrationMetrics | ||
repository: https://github.com/carmonalab/scIntegrationMetrics | ||
min: 0 | ||
max: 1 | ||
maximize: true | ||
resources: | ||
- type: r_script | ||
path: script.R | ||
engines: | ||
- type: docker | ||
image: openproblems/base_r:1 | ||
setup: | ||
- type: r | ||
github: https://github.com/carmonalab/[email protected] | ||
runners: | ||
- type: executable | ||
- type: nextflow | ||
directives: | ||
label: [midtime,midmem,midcpu] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
library(anndata) | ||
library(scIntegrationMetrics) | ||
|
||
## VIASH START | ||
par <- list( | ||
input_integrated = "resources_test/task_batch_integration/cxg_immune_cell_atlas/integrated_processed.h5ad", | ||
input_solution = "resources_test/task_batch_integration/cxg_immune_cell_atlas/solution.h5ad", | ||
output = "output.h5ad" | ||
) | ||
meta <- list( | ||
name = "cilisi" | ||
) | ||
## VIASH END | ||
|
||
cat("Reading input files\n") | ||
adata <- anndata::read_h5ad(par[["input_integrated"]]) | ||
solution <- anndata::read_h5ad(par[["input_solution"]]) | ||
embeddings <- adata$obsm[["X_emb"]] | ||
metadata <- solution$obs | ||
|
||
cat("Compute CiLISI metrics...\n") | ||
lisisplit <- | ||
scIntegrationMetrics::compute_lisi_splitBy( | ||
X = embeddings, | ||
meta_data = metadata, | ||
label_colnames = "batch", | ||
perplexity = 30, | ||
split_by_colname = "cell_type", | ||
normalize = TRUE, | ||
min.cells.split = 10, | ||
min.vars.label = 2 | ||
) | ||
# average CiLISI | ||
cilisi <- mean(unlist(lisisplit)) | ||
# Mean per cell type | ||
cilisi_means <- mean(sapply(lisisplit, function(x) mean(x[, 1]))) | ||
|
||
cat("Write output AnnData to file\n") | ||
output <- anndata::AnnData( | ||
shape = c(1,2), | ||
uns = list( | ||
dataset_id = adata$uns[["dataset_id"]], | ||
normalization_id = adata$uns[["normalization_id"]], | ||
method_id = adata$uns[["method_id"]], | ||
metric_ids = c("cilisi", "cilisi_means"), | ||
metric_values = list(cilisi, cilisi_means) | ||
) | ||
) | ||
output$write_h5ad(par[["output"]], compression = "gzip") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.