Attaching a table to a shape element can drop its shapes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 R/utils.R 中的 .sync_shapes_on_drop() 开始,并将其实例匹配方式与 .sync_tables_on_crop() 中描述的查找方式进行比较。使用示例 store 和实例 ID 从 0 开始的表格,重现行被删除时的行为。完成标准是附加表格后保留所有匹配的 shape 行;为这种情况添加回归测试。
由索引模型根据 Issue 内容生成。
描述
When a table annotating a shape element is attached, .sync_shapes_on_drop() subsets the element with
y <- y[match(instances(t), instances(y), nomatch = 0)]
(R/utils.R, line 45, at 58ec915). For a shape element without an instance_key attribute, instances(y) returns seq_len(nrow(y)), so the table's instance values end up matched against row positions. With ids that start at 0, the last shape goes missing.
A reprex with the example store, on spatialdataR 0.99.44:
library(spatialdataR)
x <- readSpatialData(system.file("extdata", "blobs.zarr", package = "spatialdataR"))
nrow(shape(x, "blobs_circles"))
#> [1] 5
t <- table(x)[, 1:5]
regions(t) <- "blobs_circles"
instances(t) <- 0:4
table(x, "circles") <- t
nrow(shape(x, "blobs_circles"))
#> [1] 4
With a two-column table and instances(t) <- c(4L, 5L), the element ends up with no rows at all, although shape(x, "blobs_circles")[c(4, 5)] on its own returns two.
The same happens when reading two of the example stores in the BiocSpatialData OSN bucket. In merfish.zarr.zip, cells has 2,389 rows in shapes.parquet and 2,389 columns in the table, but 2,388 rows after readSpatialData(); in visium_associated_xenium_io_aligned.zip the spots go from 4,992 to 4,991. Both number their instances from 0. With tables = FALSE every row is there, and xenium_rep1_io_aligned.zip, whose ids start at 1, keeps all of them.
In these stores the ids sit in a column named after the table's instance key (cell_id, spot_id), which is what .sync_tables_on_crop() already looks for with if (ik %in% names(e)) e[[ik]], so the same lookup would probably fix it here. Something else I noticed along the way: [ on a shape element keeps rows in their stored order, so circles[c(3, 1)] returns rows 1 and 3.
This may fit with #195. Happy to put together a PR with a test if that helps.
- 主要语言
- R
- 星标
- 37
- 派生
- 10
- 平均合并
- 22 小时 46 分钟
- 30 天内合并 PR
- 20
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HelenaLC/spatialdataR 的其他 Issue
-
axes order in image/label show method可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
HelenaLC/spatialdataR#239 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 60/100
HelenaLC/spatialdataR#271 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
HelenaLC/spatialdataR#251 · 6 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
HelenaLC/spatialdataR#241 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
HelenaLC/spatialdataR#217 ·
维护者通常 1 天内回复
查看 HelenaLC/spatialdataR 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
AlexsLemonade/scpca-nf#1357 ·
-
bug
难度 1/5 1 小时以内 新手友好度 92/100
REditorSupport/vscode-R#1883 ·
维护者通常 1 天内回复
-
Error out post processing step if there are multiple folders in /exec with the same index number未关闭
难度 2/5 1-3 小时 新手友好度 74/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100