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

Use _make_obs_column_categorical for CategoricalJointObsmField #1417

Merged
merged 5 commits into from Mar 10, 2022

Conversation

justjhong
Copy link
Contributor

Fixes #1410

@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

Merging #1417 (b54d895) into master (de2eac4) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1417      +/-   ##
==========================================
+ Coverage   91.04%   91.07%   +0.02%     
==========================================
  Files         111      111              
  Lines        8635     8630       -5     
==========================================
- Hits         7862     7860       -2     
+ Misses        773      770       -3     
Impacted Files Coverage Δ
scvi/data/_utils.py 85.29% <100.00%> (+2.76%) ⬆️
scvi/data/fields/_obs_field.py 97.95% <100.00%> (ø)
scvi/data/fields/_obsm_field.py 96.70% <100.00%> (-0.08%) ⬇️
scvi/data/fields/_scanvi.py 96.96% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de2eac4...b54d895. Read the comment docs.


# make sure each category contains enough cells
unique, counts = np.unique(adata.obs[alternate_column_key], return_counts=True)
unique, counts = np.unique(getattr(df, alternate_column_key), return_counts=True)
if np.min(counts) < 3:
category = unique[np.argmin(counts)]
warnings.warn(
"Category {} in adata.obs['{}'] has fewer than 3 cells. SCVI may not train properly.".format(
Copy link
Member

Choose a reason for hiding this comment

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

can we change this message to say "models" instead of SCVI


# make sure each category contains enough cells
unique, counts = np.unique(adata.obs[alternate_column_key], return_counts=True)
unique, counts = np.unique(getattr(df, alternate_column_key), return_counts=True)
Copy link
Member

Choose a reason for hiding this comment

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

why getattr and not df[alternate_column_key]

Copy link
Member

Choose a reason for hiding this comment

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

also wait isn't this call to np unique inefficient? We already called np unique on the codes earlier on 144?

@justjhong justjhong enabled auto-merge (squash) March 10, 2022 20:26
@justjhong justjhong disabled auto-merge March 10, 2022 20:26
@adamgayoso adamgayoso merged commit 0f73473 into master Mar 10, 2022
@adamgayoso adamgayoso deleted the jhong/categoricalnan branch March 10, 2022 22:19
meeseeksmachine pushed a commit to meeseeksmachine/scvi-tools that referenced this pull request Mar 10, 2022
adamgayoso pushed a commit that referenced this pull request Mar 10, 2022
…lJointObsmField` (#1419)

Co-authored-by: Justin Hong <jjhong922@berkeley.edu>
nrclaudio pushed a commit to nrclaudio/scvi-tools-tune that referenced this pull request Jun 21, 2022
…cverse#1417)

* refactor make obs column cat

* address comments

* release note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nan in Categorical obs leads to runtime error
2 participants