Pluot 图层参数字段设计
pluot-layer-parameter-principles
当向图层参数结构体添加字段/属性/成员时使用。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-04
- Stars
- ★ 31
- Forks
- 3
01 前言 Front Matter
- name
- pluot-layer-parameter-principles
- description
- Use when adding fields/properties/members to layer parameter structs.
03 SKILL.md 正文
Option types
Unless a property absolutely must be specified explicitly, prefer Option types in which None is the default value of the property, such that None is a sentinel value which is interpreted to mean "I want the default behavior for this property".
TypeScript types
Layer params structs, and every type they reference, must derive ts_rs::TS (alongside Serialize and Deserialize), so that @pluot/core gets strongly-typed plot_params.layers.
- New layer params structs must also be added as a variant of the
LayerParamsenum incrates/pluot/src/render_params.rs. - Struct-level
#[serde(default)]is handled on the TS side, wherelayer_paramsis wrapped inPartial. - On nested (non-layer-params) structs that have
Optionfields, add#[ts(optional_fields = nullable)], since serde allows those fields to be omitted. - On fields with field-level
#[serde(default)]or#[serde(default = "...")], add#[ts(optional = nullable)]. - For types from external crates, or types with custom
Serialize/Deserializeimpls, use#[ts(type = "...")]to give the TypeScript type of their serialized form (e.g.,OmeDimensionOrderserializes to astring).
After changing any of these types, run pnpm run generate-types.
Scverse data structure parameters: AnnData, MuData, SpatialData
When defining parameters for AnnData layers (layers prefixed with the name Adata or adata_), references to particular dataframe columns or items within key-value mappings such as obsm/varm should require the user to specify the entire path to the column or mapping, relative to the root of the AnnData object.
For example, rather than var_column: "highly_variable" with an implicit assumption that this column is within the var dataframe, the parameter should be var_column_path: "var/highly_variable".
This ensures that the code is also compatible with MuData or SpatialData objects, where the path to such a column may be nested one or more levels deeper, such as var_column_path: "mod/rna/var/highly_variable" or var_column_path: "tables/my_table/var/highly_variable".
For expression matrices, rather than layer, prefer layer_path which can then accept layer_path: "X", layer_path: "layers/log1p", layer_path: "tables/my_table/layers/log1p", etc.
For var index values (e.g., gene names) and obs index values (e.g., cell barcodes), by default use the dataframe indices specified in the Zarr attrs metadata. However, always allow the user to specify the path to these index columns explicitly (in case the index stores identifiers using a different system such as ENSG gene IDs yet the user wants to refer to genes via Gene Symbols which are stored in a different dataframe column).
When defining groupby parameters, when possible, support nested groupbys defined in terms of column paths from coarsest to finest-grained groupings using a value type such as Vec<String>.
04 同仓库更多 Skills
Snappy Rust 构建故障排查
pluot-snappy-troubleshooting
当 Rust 构建因命令未成功执行而失败时使用,涉及 snappy、snappy_src 或 snappy/snappy.cc。
WGSL 着色器模块开发
pluot-shader-modules
当您需要编写或修改 WGSL 着色器时使用。
Pluot 开发参考资料检索
pluot-reference-materials
当用户要求您引用特定的代码、文档文件,或依赖项及相关工具的源代码仓库时使用。
Pluot 层数据缓存与记忆化
pluot-memoization
在编写层准备函数时使用,这些函数异步加载数据或以其他方式需要缓存或记忆化结果。
Pluot Rust 图层实现
pluot-layer-implementation
当使用 Rust 为 Pluot 实现图层时使用。
Pluot 过滤选择高亮
pluot-filter-select-highlight
当修改 Pluot 中的过滤、选择或高亮逻辑时使用。