`render_points` with column coloring throws error when there are too many points
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
Recommendation: attach a minimal working example
Minimal working example with a toy dataset:
from spatialdata.models import PointsModel
n_points=10000
coords = pd.DataFrame({'x': np.random.rand(n_points),
'y': np.random.rand(n_points)})
points = PointsModel.parse(coords)
points_sdata = sd.SpatialData(points={"points": points})
obs = pd.DataFrame()
obs["instance_id"] = np.arange(n_points)
obs["region"] = "points"
obs["region"].astype("category")
obs["feature"] = np.random.rand(n_points)
table = AnnData(X=np.random.rand(n_points, 1), obs=obs)
points_sdata['table'] = TableModel.parse(table, region='points', region_key='region', instance_key='instance_id')
points_sdata.pl.render_points('points', color='feature', size=100).pl.show()
Describe the bug
Changing n_points from 10000 to 10001 and greater values gives the error: KeyError: 'feature' which is very annoying because I work with very large single cell datasets.
My assessment:
looking at this source code
if method is None:
method = "datashader" if len(points) > 10000 else "matplotlib"
it seems that the problem is due to using the datashader backend?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the render_points entry point and inspect the automatic method selection around the 10,000-point threshold, reproducing the supplied example with 10,000 and 10,001 points. Trace how the feature column is handled by the large-point rendering path; done means column coloring works without KeyError for datasets above the threshold.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100