-
Notifications
You must be signed in to change notification settings - Fork 17
render_labels
and render_shapes
now scan for and respect xyz_colors in adata.uns
#492
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
Open
timtreis
wants to merge
10
commits into
main
Choose a base branch
from
bugfix/issue403-render_labels-color-plot-no-longer-working2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0df4c97
now respecting uns color
timtreis 42a63f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4603fdd
added tests
timtreis e077e6a
merge
timtreis 5333d45
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5d7790f
updated behaviour
timtreis 8e5efc5
merge
timtreis 845038a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bfdf279
mypy
timtreis 9086821
pic from runner
timtreis 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
from anndata import AnnData | ||
from matplotlib.colors import Normalize | ||
from shapely.geometry import MultiPolygon, Point, Polygon | ||
from spatialdata import SpatialData, deepcopy | ||
from spatialdata import SpatialData, deepcopy, get_element_instances | ||
from spatialdata.models import ShapesModel, TableModel | ||
from spatialdata.transformations import Affine, Identity, MapAxis, Scale, Sequence, Translation | ||
from spatialdata.transformations._utils import _set_transformations | ||
|
@@ -562,6 +562,30 @@ def test_plot_can_annotate_shapes_with_table_layer(self, sdata_blobs: SpatialDat | |
|
||
sdata_blobs.pl.render_shapes("blobs_circles", color="feature0", table_layer="normalized").pl.show() | ||
|
||
def test_plot_respects_custom_colors_from_uns(self, sdata_blobs: SpatialData): | ||
labels_name = "blobs_labels" | ||
instances = get_element_instances(sdata_blobs[labels_name]) | ||
n_obs = len(instances) | ||
adata = AnnData( | ||
get_standard_RNG().normal(size=(n_obs, 10)), | ||
obs=pd.DataFrame(get_standard_RNG().normal(size=(n_obs, 3)), columns=["a", "b", "c"]), | ||
) | ||
adata.obs["instance_id"] = instances.values | ||
adata.obs["category"] = get_standard_RNG().choice(["a", "b", "c"], size=adata.n_obs) | ||
adata.obs["category"][:3] = ["a", "b", "c"] | ||
adata.obs["region"] = labels_name | ||
table = TableModel.parse( | ||
adata=adata, | ||
region_key="region", | ||
instance_key="instance_id", | ||
region=labels_name, | ||
) | ||
sdata_blobs["other_table"] = table | ||
sdata_blobs["other_table"].obs["category"] = sdata_blobs["other_table"].obs["category"].astype("category") | ||
sdata_blobs["other_table"].uns["category_colors"] = ["#800080", "#008000", "#FFFF00"] # purple, green ,yellow | ||
|
||
sdata_blobs.pl.render_labels("blobs_labels", color="category").pl.show() | ||
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. Correct me if I'm wrong but shouldn't this all be about shapes and not plotting the labels again? |
||
|
||
|
||
def test_warns_when_table_does_not_annotate_element(sdata_blobs: SpatialData): | ||
# Work on an independent copy since we mutate tables | ||
|
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.
hmm, do we really expect that the user passes a hex?