-
Notifications
You must be signed in to change notification settings - Fork 2
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 annotation of potential doublets to anndata obs #193
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8ad1a9b
adding annotation of potential doublets
ptajvar e08516d
split _compute_sub_communities from _assess_doublet
ptajvar 128f116
Added n_edges_to_split_potential_doublets
ptajvar 42b1537
Reduced Leiden resolution by 0.5 in the annotation step
ptajvar 7a3e5c1
updated CHANGELOG.md
ptajvar 2b03001
fix: set default values for fraction_potential_doublets and n_edges_t…
ptajvar 4d38f39
fix: make fraction_potential_doublets non-optional
ptajvar 13f6618
Update src/pixelator/pixeldataset/utils.py
ptajvar a427c36
Update src/pixelator/pixeldataset/utils.py
ptajvar 19bd66a
Update src/pixelator/pixeldataset/utils.py
ptajvar 2e46451
Update src/pixelator/pixeldataset/utils.py
ptajvar 8db21e2
fix: typo
ptajvar 98da20f
added RELATIVE_ANNOTATE_RESOLUTION as a constant
ptajvar 69041e7
make fraction_potential_doublets and n_edges_to_split_potential_doubl…
ptajvar 63b4ef1
set default fraction_potential_doublets and n_edges_to_split_potentia…
ptajvar fb156c9
explicitly check n_edges_to_split_doublet exists before using sum
ptajvar 7042c1f
fix: typecheck
ptajvar 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 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 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 |
---|---|---|
|
@@ -376,6 +376,8 @@ class AnnotateAnndataStatistics(typing.TypedDict): | |
min_size_threshold: Optional[int] | ||
max_size_threshold: Optional[int] | ||
doublet_size_threshold: Optional[int] | ||
fraction_potential_doublets: Optional[float] | ||
n_edges_to_split_potential_doublets: Optional[int] | ||
|
||
|
||
def anndata_metrics(adata: AnnData) -> AnnotateAnndataStatistics: | ||
|
@@ -412,6 +414,8 @@ def anndata_metrics(adata: AnnData) -> AnnotateAnndataStatistics: | |
"min_size_threshold": None, | ||
"max_size_threshold": None, | ||
"doublet_size_threshold": None, | ||
"fraction_potential_doublets": None, | ||
"n_edges_to_split_potential_doublets": None, | ||
} | ||
|
||
# Tau type will only be available if it has been added in the annotate step | ||
|
@@ -433,4 +437,14 @@ def anndata_metrics(adata: AnnData) -> AnnotateAnndataStatistics: | |
if "doublet_size_threshold" in adata.uns: | ||
metrics["doublet_size_threshold"] = adata.uns["doublet_size_threshold"] | ||
|
||
if "is_potential_doublet" in adata.obs: | ||
metrics["fraction_potential_doublets"] = adata.obs[ | ||
"is_potential_doublet" | ||
].mean() | ||
|
||
if "n_edges_to_split_doublet" in adata.obs: | ||
metrics["n_edges_to_split_potential_doublets"] = adata.obs[ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with sum |
||
"n_edges_to_split_doublet" | ||
].sum() | ||
|
||
return metrics |
This file contains 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 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 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 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 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 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 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 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
6 changes: 3 additions & 3 deletions
6
tests/report/snapshots/test_annotate/test_annotate_summary/annotate_summary.csv
This file contains 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
sample_id,fraction_molecules_in_largest_component,fraction_pixels_in_largest_component,input_cell_count,input_read_count,cell_count,marker_count,total_marker_count,molecule_count,a_pixel_count,b_pixel_count,read_count,aggregate_count,molecules_in_aggregates_count,reads_in_aggregates_count,min_size_threshold,max_size_threshold,doublet_size_threshold,size_filter_fail_cell_count,size_filter_fail_molecule_count,size_filter_fail_read_count,pixel_count,fraction_aggregate_components,fraction_reads_in_aggregates,fraction_molecules_in_aggregates,molecule_count_per_cell_mean,molecule_count_per_cell_std,molecule_count_per_cell_min,molecule_count_per_cell_q1,molecule_count_per_cell_q2,molecule_count_per_cell_q3,molecule_count_per_cell_max,molecule_count_per_cell_count,molecule_count_per_cell_iqr,read_count_per_cell_mean,read_count_per_cell_std,read_count_per_cell_min,read_count_per_cell_q1,read_count_per_cell_q2,read_count_per_cell_q3,read_count_per_cell_max,read_count_per_cell_count,read_count_per_cell_iqr,a_pixel_count_per_cell_mean,a_pixel_count_per_cell_std,a_pixel_count_per_cell_min,a_pixel_count_per_cell_q1,a_pixel_count_per_cell_q2,a_pixel_count_per_cell_q3,a_pixel_count_per_cell_max,a_pixel_count_per_cell_count,a_pixel_count_per_cell_iqr,b_pixel_count_per_cell_mean,b_pixel_count_per_cell_std,b_pixel_count_per_cell_min,b_pixel_count_per_cell_q1,b_pixel_count_per_cell_q2,b_pixel_count_per_cell_q3,b_pixel_count_per_cell_max,b_pixel_count_per_cell_count,b_pixel_count_per_cell_iqr,marker_count_per_cell_mean,marker_count_per_cell_std,marker_count_per_cell_min,marker_count_per_cell_q1,marker_count_per_cell_q2,marker_count_per_cell_q3,marker_count_per_cell_max,marker_count_per_cell_count,marker_count_per_cell_iqr,a_pixel_b_pixel_ratio_per_cell_mean,a_pixel_b_pixel_ratio_per_cell_std,a_pixel_b_pixel_ratio_per_cell_min,a_pixel_b_pixel_ratio_per_cell_q1,a_pixel_b_pixel_ratio_per_cell_q2,a_pixel_b_pixel_ratio_per_cell_q3,a_pixel_b_pixel_ratio_per_cell_max,a_pixel_b_pixel_ratio_per_cell_count,a_pixel_b_pixel_ratio_per_cell_iqr,molecule_count_per_a_pixel_per_cell_mean,molecule_count_per_a_pixel_per_cell_std,molecule_count_per_a_pixel_per_cell_min,molecule_count_per_a_pixel_per_cell_q1,molecule_count_per_a_pixel_per_cell_q2,molecule_count_per_a_pixel_per_cell_q3,molecule_count_per_a_pixel_per_cell_max,molecule_count_per_a_pixel_per_cell_count,molecule_count_per_a_pixel_per_cell_iqr,b_pixel_count_per_a_pixel_per_cell_mean,b_pixel_count_per_a_pixel_per_cell_std,b_pixel_count_per_a_pixel_per_cell_min,b_pixel_count_per_a_pixel_per_cell_q1,b_pixel_count_per_a_pixel_per_cell_q2,b_pixel_count_per_a_pixel_per_cell_q3,b_pixel_count_per_a_pixel_per_cell_max,b_pixel_count_per_a_pixel_per_cell_count,b_pixel_count_per_a_pixel_per_cell_iqr,a_pixel_count_per_b_pixel_per_cell_mean,a_pixel_count_per_b_pixel_per_cell_std,a_pixel_count_per_b_pixel_per_cell_min,a_pixel_count_per_b_pixel_per_cell_q1,a_pixel_count_per_b_pixel_per_cell_q2,a_pixel_count_per_b_pixel_per_cell_q3,a_pixel_count_per_b_pixel_per_cell_max,a_pixel_count_per_b_pixel_per_cell_count,a_pixel_count_per_b_pixel_per_cell_iqr | ||
pbmcs_unstimulated,0.0006480881399870382,0.0004888381945576015,3052,6237,3052,68,80,3086,3077,3060,6237,3052,3086,6237,,,,0,0,0,6137,1.0,1.0,1.0,1.011140235910878,0.1049577584303709,1.0,1.0,1.0,1.0,2.0,3052,0.0,2.043577981651376,0.2592989644447359,2.0,2.0,2.0,2.0,5.0,3052,0.0,1.0081913499344692,0.0901346310843966,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0075360419397117,0.08648265728800528,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0068807339449541,0.09380465569259074,0.5,1.0,1.0,1.0,2.0,3052,0.0,1.0029488859764089,0.05422351932424758,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0 | ||
uropod_control,0.0007451564828614009,0.000501378791677112,3963,8117,3963,68,80,4026,3996,3982,8117,3963,4026,8117,,,,0,0,0,7978,1.0,1.0,1.0,1.015897047691143,0.1309898320781511,1.0,1.0,1.0,1.0,3.0,3963,0.0,2.0481958112541006,0.2970944331488577,2.0,2.0,2.0,2.0,7.0,3963,0.0,1.008327024981075,0.09360744530597291,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.0047943477163765,0.06907504575713982,1.0,1.0,1.0,1.0,2.0,3963,0.0,1.0136260408781226,0.1180891191803105,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.005803684077719,0.09839298617811536,0.5,1.0,1.0,1.0,3.0,3963,0.0,1.0074438556649004,0.0884874529853118,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.0046681806712088,0.0677001125393875,1.0,1.0,1.0,1.0,2.0,3963,0.0,1.0046681806712088,0.0677001125393875,1.0,1.0,1.0,1.0,2.0,3963,0.0 | ||
sample_id,fraction_molecules_in_largest_component,fraction_pixels_in_largest_component,fraction_potential_doublets,n_edges_to_split_potential_doublets,input_cell_count,input_read_count,cell_count,marker_count,total_marker_count,molecule_count,a_pixel_count,b_pixel_count,read_count,aggregate_count,molecules_in_aggregates_count,reads_in_aggregates_count,min_size_threshold,max_size_threshold,doublet_size_threshold,size_filter_fail_cell_count,size_filter_fail_molecule_count,size_filter_fail_read_count,pixel_count,fraction_aggregate_components,fraction_reads_in_aggregates,fraction_molecules_in_aggregates,molecule_count_per_cell_mean,molecule_count_per_cell_std,molecule_count_per_cell_min,molecule_count_per_cell_q1,molecule_count_per_cell_q2,molecule_count_per_cell_q3,molecule_count_per_cell_max,molecule_count_per_cell_count,molecule_count_per_cell_iqr,read_count_per_cell_mean,read_count_per_cell_std,read_count_per_cell_min,read_count_per_cell_q1,read_count_per_cell_q2,read_count_per_cell_q3,read_count_per_cell_max,read_count_per_cell_count,read_count_per_cell_iqr,a_pixel_count_per_cell_mean,a_pixel_count_per_cell_std,a_pixel_count_per_cell_min,a_pixel_count_per_cell_q1,a_pixel_count_per_cell_q2,a_pixel_count_per_cell_q3,a_pixel_count_per_cell_max,a_pixel_count_per_cell_count,a_pixel_count_per_cell_iqr,b_pixel_count_per_cell_mean,b_pixel_count_per_cell_std,b_pixel_count_per_cell_min,b_pixel_count_per_cell_q1,b_pixel_count_per_cell_q2,b_pixel_count_per_cell_q3,b_pixel_count_per_cell_max,b_pixel_count_per_cell_count,b_pixel_count_per_cell_iqr,marker_count_per_cell_mean,marker_count_per_cell_std,marker_count_per_cell_min,marker_count_per_cell_q1,marker_count_per_cell_q2,marker_count_per_cell_q3,marker_count_per_cell_max,marker_count_per_cell_count,marker_count_per_cell_iqr,a_pixel_b_pixel_ratio_per_cell_mean,a_pixel_b_pixel_ratio_per_cell_std,a_pixel_b_pixel_ratio_per_cell_min,a_pixel_b_pixel_ratio_per_cell_q1,a_pixel_b_pixel_ratio_per_cell_q2,a_pixel_b_pixel_ratio_per_cell_q3,a_pixel_b_pixel_ratio_per_cell_max,a_pixel_b_pixel_ratio_per_cell_count,a_pixel_b_pixel_ratio_per_cell_iqr,molecule_count_per_a_pixel_per_cell_mean,molecule_count_per_a_pixel_per_cell_std,molecule_count_per_a_pixel_per_cell_min,molecule_count_per_a_pixel_per_cell_q1,molecule_count_per_a_pixel_per_cell_q2,molecule_count_per_a_pixel_per_cell_q3,molecule_count_per_a_pixel_per_cell_max,molecule_count_per_a_pixel_per_cell_count,molecule_count_per_a_pixel_per_cell_iqr,b_pixel_count_per_a_pixel_per_cell_mean,b_pixel_count_per_a_pixel_per_cell_std,b_pixel_count_per_a_pixel_per_cell_min,b_pixel_count_per_a_pixel_per_cell_q1,b_pixel_count_per_a_pixel_per_cell_q2,b_pixel_count_per_a_pixel_per_cell_q3,b_pixel_count_per_a_pixel_per_cell_max,b_pixel_count_per_a_pixel_per_cell_count,b_pixel_count_per_a_pixel_per_cell_iqr,a_pixel_count_per_b_pixel_per_cell_mean,a_pixel_count_per_b_pixel_per_cell_std,a_pixel_count_per_b_pixel_per_cell_min,a_pixel_count_per_b_pixel_per_cell_q1,a_pixel_count_per_b_pixel_per_cell_q2,a_pixel_count_per_b_pixel_per_cell_q3,a_pixel_count_per_b_pixel_per_cell_max,a_pixel_count_per_b_pixel_per_cell_count,a_pixel_count_per_b_pixel_per_cell_iqr | ||
pbmcs_unstimulated,0.0006480881399870382,0.0004888381945576015,0.0,0,3052,6237,3052,68,80,3086,3077,3060,6237,3052,3086,6237,,,,0,0,0,6137,1.0,1.0,1.0,1.011140235910878,0.1049577584303709,1.0,1.0,1.0,1.0,2.0,3052,0.0,2.043577981651376,0.2592989644447359,2.0,2.0,2.0,2.0,5.0,3052,0.0,1.0081913499344692,0.0901346310843966,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0075360419397117,0.08648265728800528,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0068807339449541,0.09380465569259074,0.5,1.0,1.0,1.0,2.0,3052,0.0,1.0029488859764089,0.05422351932424758,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0,1.0026212319790302,0.05113082359929531,1.0,1.0,1.0,1.0,2.0,3052,0.0 | ||
uropod_control,0.0007451564828614009,0.000501378791677112,0.0,0,3963,8117,3963,68,80,4026,3996,3982,8117,3963,4026,8117,,,,0,0,0,7978,1.0,1.0,1.0,1.015897047691143,0.1309898320781511,1.0,1.0,1.0,1.0,3.0,3963,0.0,2.0481958112541006,0.2970944331488577,2.0,2.0,2.0,2.0,7.0,3963,0.0,1.008327024981075,0.09360744530597291,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.0047943477163765,0.06907504575713982,1.0,1.0,1.0,1.0,2.0,3963,0.0,1.0136260408781226,0.1180891191803105,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.005803684077719,0.09839298617811536,0.5,1.0,1.0,1.0,3.0,3963,0.0,1.0074438556649004,0.0884874529853118,1.0,1.0,1.0,1.0,3.0,3963,0.0,1.0046681806712088,0.0677001125393875,1.0,1.0,1.0,1.0,2.0,3963,0.0,1.0046681806712088,0.0677001125393875,1.0,1.0,1.0,1.0,2.0,3963,0.0 |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are no
is_potential_doublet
here, what will it happen when run mean?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be a key error, that's why we check for it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But when
adata.obs["is_potential_doublet"]
returns empty and we calledmean()
- what happens then?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only run the mean() function if "is_potential_doublet" exists as a column in adata.obs. Otherwise that part is not run and "fraction_potential_doublets" remains the default value which is 0 right now but following the discussion we're going to change it to None.