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

Adding model with cycle consistency and VampPrior #2421

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

Conversation

Hrovatin
Copy link

@Hrovatin Hrovatin commented Jan 19, 2024

Closes #2383

@Hrovatin Hrovatin changed the title Adding model with cycle consistency and VampPrior, closes https://github.com/scverse/scvi-tools/issues/2383 Adding model with cycle consistency and VampPrior Jan 19, 2024
Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: Patch coverage is 90.25735% with 53 lines in your changes are missing coverage. Please review.

Project coverage is 89.40%. Comparing base (6062656) to head (8c25dba).
Report is 1 commits behind head on main.

❗ Current head 8c25dba differs from pull request most recent head 54f5734. Consider uploading reports for the commit 54f5734 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2421      +/-   ##
==========================================
- Coverage   89.90%   89.40%   -0.50%     
==========================================
  Files         154      161       +7     
  Lines       12629    13172     +543     
==========================================
+ Hits        11354    11777     +423     
- Misses       1275     1395     +120     
Files Coverage Δ
scvi/external/__init__.py 100.00% <100.00%> (ø)
scvi/external/sysvi/__init__.py 100.00% <100.00%> (ø)
scvi/external/sysvi/_module.py 97.67% <97.67%> (ø)
scvi/external/sysvi/_priors.py 93.18% <93.18%> (ø)
scvi/external/sysvi/_utils.py 93.75% <93.75%> (ø)
scvi/external/sysvi/_trainingplans.py 91.39% <91.39%> (ø)
scvi/external/sysvi/_model.py 92.68% <92.68%> (ø)
scvi/external/sysvi/_base_components.py 73.52% <73.52%> (ø)

... and 4 files with indirect coverage changes

Copy link
Contributor

@martinkim0 martinkim0 left a comment

Choose a reason for hiding this comment

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

Hey, thanks for putting in this PR! A couple of high-level comments for now.

Could you restructure the files as follows?

  • csi/model/_model.py -> csi/_model.py
  • csi/model/_utils.py -> csi/_utils.py
  • csi/module/_module.py -> csi/_module.py
  • csi/module/_priors.py -> csi/_priors.py
  • csi/nn/_base_components.py -> csi/_components.py
  • csi/train/_trainingplans.py -> csi/_trainingplans.py
  • Refactor csi/module/_module.py to use scvi.module.base.LossOutput instead of our previous LossRecorder and remove csi/module/_loss_recoder.py
  • If the plan is to directly inherit from UnsupervisedTrainingMixin without any major changes except setting _training_plan_cls, this can be done within _model.py by directly subclassing UnsupervisedTrainingMixin and setting _training_plan_cls there instead, so I would recommend doing that and deleting csi/model/_training.py

I can take a look at compatibility with scArches in the next round.

We're also slowly migrating to newer typing annotations in Python. Could you add a from __future__ import annotations to the top of every file (except __init__.pys) and migrate typing from:

  • Optional[x] -> x | None
  • Union[x, y] -> x | y
  • List[x] -> list[x]
  • Tuple[x] -> tuple[x]
  • Callable -> callable
  • There's more, I don't remember all of them. The pre-commit hooks will warn about missing ones.

@martinkim0 martinkim0 added this to the scvi-tools 1.2.0 milestone Jan 19, 2024
@Hrovatin
Copy link
Author

I added changes and adapted tutorial accrordingly

@martinkim0
Copy link
Contributor

Thanks for addressing the comments! I'll take another pass at it soon.

Copy link
Contributor

@martinkim0 martinkim0 left a comment

Choose a reason for hiding this comment

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

Some minor typing/style comments as well as implementation ones. I still don't understand all parts of the implementation so I will take another pass at this

scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_base_components.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_model.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_module.py Outdated Show resolved Hide resolved
scvi/external/sysvi/_priors.py Outdated Show resolved Hide resolved
@martinkim0 martinkim0 added the cuda tests Run test suite on CUDA label Feb 5, 2024
@Hrovatin
Copy link
Author

Hrovatin commented Feb 7, 2024

@martinkim0 thank you for looking at it again - I added the changes as requested

@martinkim0
Copy link
Contributor

Sorry for the delay in reviewing this - hopefully taking a last pass this week and we get this merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda tests Run test suite on CUDA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding cycle consistency loss and VampPrior to scVI
2 participants