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

feat: scib-autotune #3168

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

feat: scib-autotune #3168

wants to merge 21 commits into from

Conversation

ori-kron-wis
Copy link
Collaborator

re open the scib-autotune branch
see: #2593
#2517

@ori-kron-wis ori-kron-wis added the on-merge: backport to 1.2.x on-merge: backport to 1.2.x label Jan 28, 2025
@ori-kron-wis ori-kron-wis added this to the scvi-tools 1.2 milestone Jan 28, 2025
@ori-kron-wis ori-kron-wis self-assigned this Jan 28, 2025
@ori-kron-wis ori-kron-wis marked this pull request as ready for review February 11, 2025 15:57
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 23.52941% with 91 lines in your changes missing coverage. Please review.

Project coverage is 82.25%. Comparing base (50e8bab) to head (dce56d4).

Files with missing lines Patch % Lines
src/scvi/train/_callbacks.py 10.00% 81 Missing ⚠️
src/scvi/train/_trainingplans.py 55.55% 8 Missing ⚠️
src/scvi/autotune/_experiment.py 81.81% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (50e8bab) and HEAD (dce56d4). Click for more details.

HEAD has 9 uploads less than BASE
Flag BASE (50e8bab) HEAD (dce56d4)
12 3
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3168      +/-   ##
==========================================
- Coverage   89.43%   82.25%   -7.19%     
==========================================
  Files         185      185              
  Lines       16182    16297     +115     
==========================================
- Hits        14473    13405    -1068     
- Misses       1709     2892    +1183     
Files with missing lines Coverage Δ
src/scvi/autotune/_tune.py 76.47% <ø> (ø)
src/scvi/module/_vae.py 94.92% <ø> (ø)
src/scvi/autotune/_experiment.py 87.21% <81.81%> (+0.09%) ⬆️
src/scvi/train/_trainingplans.py 92.38% <55.55%> (-1.25%) ⬇️
src/scvi/train/_callbacks.py 56.03% <10.00%> (-29.18%) ⬇️

... and 27 files with indirect coverage changes

from scib_metrics.benchmark import BatchCorrection, BioConservation

def __init__(
self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete function documentation. What's num rows to select?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its the number of random rows we want to perform the scib metric calculation based on

# adjust which metric to run exactly
found_metric = next(
(key for key, value in metric_name_cleaner.items() if value == self.metric), None
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it return a single metric? How are different metrics executed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what is the metric_name_cleaner dict in scib_metrics/benchmark/_core.py.
The idea is that the user tells which metric to optimize the tuning by.
It can be any metric in the scib-metrics list. Here Im just checking that the metric exists in the list and according to this decide which metrics to calculate (selecting the flags in BioConservation and BatchCorrection) and if we are to optimize and aggregated metric, than the whole vector will be turned on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we dont have to even do that and just stick to the metric name

(key for key, value in metric_name_cleaner.items() if value == self.metric), None
)
# special cases:
if self.metric == "Leiden NMI" or self.metric == "Leiden ARI":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to change this directly in scib-metric. New argument for single metric.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting with this for now

> 0
):
# TODO: subsample to save time already here?
x = loss_outputs["x"].detach().cpu()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be very memory intensive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subsampling should be to the same cells in a ray tune run. Maybe expose the indices instead? It would also make it more flexible to e.g. set one single dataset as scib cells.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont really need X. Ill change that and Ill add the option to input specific indices

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remember that this while mechanism works only if we set to scib tune

@ori-kron-wis ori-kron-wis added on-merge: backport to 1.3.x on-merge: backport to 1.3.x and removed on-merge: backport to 1.2.x on-merge: backport to 1.2.x labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-merge: backport to 1.3.x on-merge: backport to 1.3.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants