schard h5ad 转换

SKILLAI 工具
AI 工具 未标注权限 许可证不明确
安装这个技能

Chat2Research Al科研工作台:Use when converting h5ad (scanpy/AnnData) files into Seurat or SingleCellExperiment objects in R. Pure-R, reticulate-free loading of X/obs/var/obsm and Visium images via schard.(Skill由Chat2Research Al科研工作台:https://icell.abiosciences.cn/?source=20e0489c 提供,登录平台可享免费算力和Token及更多分析组学Skills)

一句话选型结论

按资料字段整理

schard h5ad 转换是AI 工具类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类AI 工具 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_7ece4fea/schard-h5ad-conversion
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

AI 工具
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_7ece4fea仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791622169
正文体量18.2 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
组合多个 AI 能力

把写作、检索、总结串成一条流程。

搭工作流

把固定流程做成可重复调用的步骤。

做提示词与评测

整理提示词并对比输出效果。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在AI 工具场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
schard h5ad 转换当前 未标注权限 未标注 未标注 未标注 有
执行计划 只读 GitHub 仓库 151.5 万 Codex、Claude、Cursor 有
Playwright MCP 测试 浏览器控制 ClawHub 市场 136.5 万 OpenClaw 有
完成前的验证 未标注权限 GitHub 仓库 131.9 万 Codex、Claude、Cursor 有
子 Agent 驱动开发 只读 GitHub 仓库 131.2 万 Codex、Claude、Cursor 有
前端设计 执行命令 GitHub 仓库 125.6 万 Codex、Claude、Cursor 有

SKILL.md 全文

18.2 KB
模型实际读到的说明书原文,来自技能仓库

schard — h5ad → Seurat / SingleCellExperiment (pure R)

schard reads scanpy/AnnData .h5ad files into R without Python: it parses the HDF5
file directly with rhdf5 and builds SingleCellExperiment or Seurat objects.
Upstream: <https://github.com/cellgeni/schard> (default branch main, version 1.1.0, not on CRAN/Bioconductor).

When to Use

  • An .h5ad (cellxgene, Sanger atlas, or your own scanpy pipeline) must be analysed in R.
  • The usual route is broken or annoying: sceasy needs reticulate + a working Python env,
    SeuratDisk needs an intermediate .h5Seurat and is barely maintained.
  • You need Visium spatial data out of an h5ad with its images and spot coordinates, not just the matrix.
  • You only want to read a slice of an h5ad (e.g. obs or one obsm embedding) without loading expression.

Not for: writing h5ad (schard is read-only), or .h5Seurat files (that is SeuratDisk).

Overview

schard loads X, obs, var, obsm (as reductions), raw and — for Visium —
/uns/spatial/&lt;library_id&gt;/images + scalefactors, then assembles the target object.
It deliberately does not carry uns, obsp, varm, varp, or layers other than those
you explicitly request through layers=. Everything is plain R + rhdf5; no Python, no reticulate,
so it works in containers where conda/reticulate handshakes fail.

Three entry points (plus two low-level helpers):

h5ad content function returns
any h5ad2sce(path) SingleCellExperiment (single assay named X)
any, non-spatial h5ad2seurat(path) Seurat (RNA assay by default)
Visium (spots + images) h5ad2seurat_spatial(path) Seurat with Spatial assay + image(s)
one slot only h5ad2data.frame(path, &#x27;obs&#x27;), h5ad2Matrix(path, &#x27;obsm/X_umap&#x27;) data.frame / matrix

Inputs

Slots that must exist in the h5ad for each target (verified against the upstream sources
R/functions.R and R/h5ad_util.R):

slot sce seurat seurat_spatial notes
/X (csr/csc sparse or dense) required required required --no-load-x zero-fills it instead
/obs required required required cell metadata; rownames come from its _index column
/var required required required feature metadata (rowData / feature meta.data)
/obsm/&lt;name&gt; optional (load.obsm=TRUE) optional required (spatial or X_spatial for coordinates)
/raw/{X,var} optional (use.raw=TRUE) optional (use.raw=TRUE) optional absent ⇒ use.raw=TRUE errors
/layers/&lt;name&gt; not used via layers= not used also accepts the literals X / raw.X
/uns/spatial/&lt;library_id&gt;/images/{lowres,hires} + scalefactors not used not used required one image resolution is attached
an obs column whose values ⊆ names(uns/spatial) not used not used required* *or a single library, or schard stops

Is X counts or log-normalized? (decide BEFORE trusting the object)

schard does not care: it drops whatever X (or raw.X) is into the Seurat counts slot.
For vis.heart.h5ad, sn.heart.h5ad and ba16.h5ad that is wrong — measured, not guessed:

file X/data (probe of 20 000 values) /raw/X/data verdict
ba16.h5ad float, min 0.51 max 8.27, 0 % integer — (no raw) X = log-normalized, counts are gone
sn.heart.h5ad float, min 0.25 max 6.39, 0 % integer min 1 max 2022, 100 % integer X = log-normalized, raw.X = counts
vis.heart.h5ad float, min 0.52 max 6.28, 0 % integer min 1 max 774, 100 % integer X = log-normalized, raw.X = counts

Rules of thumb: integer values with max ≥ 20 ⇒ raw counts; non-integer with max ≤ 30 ⇒ log1p;
non-integer with a large max ⇒ normalized but probably not log-transformed (check before DE).
uns/log1p is only a weak hint — it is present in vis.heart.h5ad and absent in
sn.heart.h5ad, although both have log-normalized X. Always trust the numbers. The script's
--dry-run does exactly this probe for you (≈1 s, reads 20 k values):

Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad sample.h5ad --dry-run
# manual alternatives:
#   R: rhdf5::h5ls(&#x27;f.h5ad&#x27;); rhdf5::h5read(&#x27;f.h5ad&#x27;,&#x27;/X/data&#x27;, index=list(1:20000))
#   py: h5py.File(&#x27;f.h5ad&#x27;)[&#x27;X/data&#x27;][:20000]

Steps

Reusable, fully parameterised script: scripts/schard_h5ad_conversion.R.txt
(no hard-coded paths; every input/output is a CLI flag).

# 0. quickstart + cheap slot inspection (does NOT need schard installed)
Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad sample.h5ad --dry-run

# sce
Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad sample.h5ad --to sce --output-rds sample_sce.rds

# seurat (adata.X into the counts slot -- only if X really is counts)
Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad sample.h5ad --to seurat --output-rds sample.rds

# seurat with REAL counts
Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad sample.h5ad --to seurat --use-raw --output-rds cnt.rds

# spatial: one object per slide, hires image
Rscript scripts/schard_h5ad_conversion.R.txt --input-h5ad vis.h5ad --to seurat_spatial \
        --no-simplify --img-res hires --output-rds vis_list.rds

# batch directory
Rscript scripts/schard_h5ad_conversion.R.txt --input-dir ./h5ads --glob &#x27;*.h5ad&#x27; --to sce --output-dir ./sce

The five package calls, as the upstream README / user script uses them:

library(schard)

## 1) SingleCellExperiment ---------------------------------------------------
ba16.sce &lt;- schard::h5ad2sce(&#x27;ba16.h5ad&#x27;)            # assay named &quot;X&quot;
# use.raw=TRUE swaps adata.X for adata.raw.X; load.obsm=FALSE skips the reductions

## 2) Seurat (non-spatial) ---------------------------------------------------
snhx &lt;- schard::h5ad2seurat(&#x27;sn.heart.h5ad&#x27;)
Seurat::DimPlot(snhx, group.by = &#x27;cell_state&#x27;, reduction = &#x27;Xumap_&#x27;)   # h5ad &#x27;X_umap&#x27; -&gt; Seurat &#x27;Xumap_&#x27;

## 3) Visium / spatial -------------------------------------------------------
visx &lt;- schard::h5ad2seurat_spatial(&#x27;vis.heart.h5ad&#x27;)
Seurat::SpatialDimPlot(visx, group.by = &#x27;cell_type&#x27;, ncol = 2)
Seurat::SpatialPlot(visx, features = &#x27;total_counts&#x27;, images = &#x27;HCAHeartST11702009&#x27;)

## 4) raw counts instead of the (log-normalized) adata.X ---------------------
snhr &lt;- schard::h5ad2seurat(&#x27;sn.heart.h5ad&#x27;, use.raw = TRUE)
visr &lt;- schard::h5ad2seurat_spatial(&#x27;vis.heart.h5ad&#x27;, use.raw = TRUE)
plot(colSums(visx), colSums(visr), pch = 16)          # they really are different matrices

## 5) one Seurat object per slide (list) -------------------------------------
visl &lt;- schard::h5ad2seurat_spatial(&#x27;vis.heart.h5ad&#x27;, simplify = FALSE)
Seurat::SpatialPlot(visl$HCAHeartST11702010, features = &#x27;total_counts&#x27;)

## 6) matrices / routing layers into Seurat slots (v1.1.0 feature) -----------
seu &lt;- schard::h5ad2seurat(&#x27;adata.h5ad&#x27;, layers = c(counts = &#x27;raw.X&#x27;, data = &#x27;X&#x27;))
# &#x27;layers&#x27; wins over &#x27;use.raw&#x27;; only &#x27;counts&#x27; is mandatory (data / scale.data optional)

## 7) metadata only, no expression ------------------------------------------
obs  &lt;- schard::h5ad2data.frame(&#x27;sn.heart.h5ad&#x27;, &#x27;obs&#x27;)          # keep.rownames.as.column=TRUE
umap &lt;- t(schard::h5ad2Matrix(&#x27;sn.heart.h5ad&#x27;, &#x27;/obsm/X_umap&#x27;)) # obsm is stored transposed
ls   &lt;- rhdf5::h5ls(&#x27;sn.heart.h5ad&#x27;); ls[ls$group == &#x27;/obsm&#x27;, ]  # discover obsm names

Parameters

Package arguments (exact upstream signatures, main @ v1.1.0) and the matching script flag:

argument signature (default) script flag meaning
filename positional --input-h5ad / --input-dir path to the .h5ad
use.raw FALSE --use-raw / --no-use-raw load adata.raw.X (+ raw/var) instead of adata.X
simplify TRUE (spatial only) --simplify / --no-simplify merge slides into one object, else return a per-slide list
assay &#x27;RNA&#x27; (h5ad2seurat) --assay-name assay name; always &#x27;Spatial&#x27; for spatial
load.obsm TRUE --load-obsm / --no-load-obsm load obsm as reductions
load.X TRUE --load-x / --no-load-x FALSE = zero-filled matrix (much faster)
layers NULL (h5ad2seurat only) --layers &#x27;counts=raw.X,data=X&#x27; route h5ad matrices into Seurat slots; overrides use.raw
img.res &#x27;lowres&#x27; --img-res lowres\|hires which Visium image to attach
image.type NULL → auto --image-type auto\|VisiumV1\|VisiumV2 auto = VisiumV2 on Seurat ≥ 5.1, else VisiumV1
use_spam FALSE (h5ad2list, h5ad2Matrix) — >2^31-1 non-zeros; needs spam+spam64, not Seurat-compatible

Script-only flags: --to sce|seurat|seurat_spatial, --output-rds,
--output-dir DIR (output root; creates Img/, Stat/, Rdata/ under it),
--manifest,
--save-meta/--no-save-meta (write &lt;name&gt;_obs.csv), --overwrite/--no-overwrite,
--glob, --recursive/--no-recursive, --dry-run, --no-inspect, --probe N,
--no-layers, --quiet, --help.
Exit code 0 = all files converted, 1 = at least one failed/skipped (a manifest CSV is always written).

Outputs

Directory layout — --output-dir is the output root; the script creates three
subdirectories under it (Img/, Stat/, Rdata/) on every run, including --dry-run:

produced file location
&lt;name&gt;_&lt;mode&gt;[_raw][_list].rds (the converted object; any .h5ad/.h5seurat/.qs side-product) &lt;out&gt;/Rdata/
schard_conversion_manifest.csv (per-file run manifest) &lt;out&gt;/Stat/
&lt;name&gt;_&lt;mode&gt;[_raw][_list]_obs.csv (cell metadata) &lt;out&gt;/Stat/
figures, if any (e.g. SpatialDimPlot / DimPlot exports) &lt;out&gt;/Img/

--output-rds FILE is the exception: it is an explicit path used verbatim, and its
directory then serves as the root for Stat/ and Img/. The run ends with a printed
summary of all three directories.

  • SCE (h5ad2sce): one assay named X; colData = obs, rowData = var;
    reducedDim(sce, &#x27;X_umap&#x27;) — reducedDim names keep the raw h5ad obsm names (no Seurat renaming);
    cell names = obs rownames (index column, make.unique-ed, and still kept as a column).
  • Seurat (h5ad2seurat): assay RNA (or --assay-name) with the h5ad matrix in the counts layer;
    obs columns in meta.data; var columns as feature metadata (seu[[&#x27;RNA&#x27;]][[]]);
    reductions renamed to Seurat style — paste0(gsub(&#x27;_&#x27;,&#x27;&#x27;,name),&#x27;_&#x27;), i.e. X_umap → Xumap_,
    X_spatial/spatial → Xspatial_, with dims named &lt;key&gt;1..n;
    feature names have _ → - and empty names → unnamed_gene_&lt;i&gt;.
  • Spatial (h5ad2seurat_spatial): assay Spatial; one image per slide under
    seu[[&#x27;&lt;library_id&gt;&#x27;]] (VisiumV2 here: Seurat 5.5.1 > 5.1), spot table with
    tissue/row/col/imagerow/imagecol, coordinates taken from obsm[[&#x27;X_spatial&#x27;]] with the two
    columns swapped internally; simplify=TRUE merges all slides (merge()) and returns the bare
    object when there is only one slide (not a list of length 1).

Pitfalls

  • adata.X is not necessarily counts — the single most expensive mistake here. In the shipped
    example files X is log1p-normalized, so h5ad2seurat(&#x27;sn.heart.h5ad&#x27;) puts non-integer values
    into the counts slot; a later NormalizeData/FindMarkers silently operates on log data.
    Probe X/data first (see Inputs) and use --use-raw / layers = c(counts=&#x27;raw.X&#x27;) when
    /raw/X exists. The script prints a counts check line for exactly this reason.
  • use.raw = TRUE on a file without /raw/X is a hard error, not the warning the docs promise:
    upstream h5ad2list calls stop(&quot;There is no raw slot ...&quot;). ba16.h5ad has no raw at all.
  • h5ad version compatibility: very old anndata (e.g. ba16.h5ad) stores obs/var/obsm as
    compound datasets at the root rather than groups. obs/var still parse (schard handles both
    factor encodings, __categories and /uns/*_categories), but obsm is looked up as
    /obsm/&lt;name&gt; groups only, so old-format obsm is silently skipped — expect no reductions.
    Newer files have groups everywhere, X_spatial in obsm, images in uns/spatial. Any h5ad
    written by a much newer anndata with unknown encoding-type values may fail to parse — then
    convert in Python (anndata → csr_matrix h5ad or zarr) first. [partly UNVERIFIED: not run here]
  • Visium library_id detection can silently drop slides: schard picks the first obs column
    whose values are all inside names(uns/spatial). In vis.heart.h5ad that column is sangerID,
    which only references 3 of the 4 libraries present under uns/spatial (HCAHeartST11702011 has
    an image but no spots), so the simplified object has 3 images, not 4 — verify with
    SeuratObject::Images(obj). With no matching column it only works for single-library files
    (it then invents a library_id column) and otherwise stops with
    "The h5ad seems to contain multiple visium samples but library is not specified correctly".
  • Spot grid metadata may be fake: vis.heart.h5ad has no in_tissue, array_row, array_col
    in obs, so schard substitutes 1/0/0. Plotting uses the real imagerow/imagecol from
    obsm, but anything relying on the array grid is meaningless. Also, the coordinates must live in
    obsm under spatial or X_spatial (other names ⇒ error).
  • One image resolution only: img.res defaults to lowres; with hires schard remaps
    scale.factors$tissue_lowres_scalef. A missing resolution warns and falls back to the other one.
  • Seurat version decides the image class: image.type=NULL → VisiumV2 for Seurat > 5.1
    (container has 5.5.1), VisiumV1 otherwise. Code digging into @coordinates/@scale.factors
    must be written for the right class.
  • Feature-name mangling for Seurat: _ → - and empty names → unnamed_gene_&lt;i&gt; (roxygen:
    "Seurat for some reasons doesn't like underscores in feature names"). This breaks joins with
    tables keyed on exact symbols; also duplicate gene symbols survive as make.unique-d rownames
    from the h5ad index, so aggregate duplicates (scanpy-side, or Seurat::AggregateExpression)
    before DE.
  • Huge matrices: > 2^31-1 non-zeros ⇒ schard stops with a pointer to use_spam=TRUE
    (spam/spam64, but that object is then not Seurat-compatible) — the realistic answer is to
    subset in Python or use --no-load-x. Memory: rhdf5::h5read materialises the whole matrix
    (vis.heart.h5ad: 36.2 M non-zeros ⇒ ~0.6 GB numeric, more once Seurat copies it), so convert
    one file per process; the script does exactly that and gc()s between files.
  • Dense, dense-looking X: if X is a dense array with > 80 % non-zero values (or > 2^31-1
    non-zeros) schard assumes it is scaled and passes it to CreateAssayObject(data=) instead of
    counts=. Check which layer ended up populated.
  • simplify=TRUE with a single slide returns the object, not a list — guard with
    inherits(x, &#x27;Seurat&#x27;) before indexing x[[1]].
  • --to sce has no spatial support: h5ad2sce has no images handling and no assay/layers
    argument; a Visium file becomes a plain SCE whose X_spatial is only a reducedDim. Use
    h5ad2seurat_spatial for spot plots.
  • h5ad2images() is internal (not in NAMESPACE): use SeuratObject::Images(obj) instead.
  • Zero-arg traps: schard must be installed (the script says so and exits 1; --dry-run works
    without it). h5ad2sce(load.X=FALSE) still returns a matrix, just an empty one.

Environment

  • Container R 4.5.3; .libPaths() = /opt/user_R_libs, /opt/public_R_libs, /opt/conda/lib/R/library.
  • Already installed: rhdf5 2.54.1, Matrix 1.7.6, Seurat 5.5.1, SeuratObject 5.4.0,
    SingleCellExperiment 1.32.0, BiocManager 1.30.27, devtools 2.5.2.
  • Not installed: schard itself — install it before converting (dry-run needs nothing extra).
    zeallot (often listed next to h5ad tooling) is not an schard dependency; spam/spam64
    are only needed for use_spam=TRUE.
  • Install:
    r BiocManager::install(&#x27;rhdf5&#x27;) # if missing # install.packages(&#x27;devtools&#x27;) devtools::install_github(&#x27;cellgeni/schard&#x27;) # main branch, v1.1.0
  • Everything documented above was read from the upstream sources at main
    (R/functions.R, R/h5ad_util.R, NAMESPACE, DESCRIPTION, README.md) and cross-checked with
    real slot probes of the three example files (ba16.h5ad, sn.heart.h5ad, vis.heart.h5ad).
    The conversion calls themselves were not executed here because schard is not installed in
    this container; only the script's inspection/reporting paths were run for real.

Files

  • scripts/schard_h5ad_conversion.R.txt — CLI wrapper around the three h5ad2* functions:
    parameterised (--to, --use-raw, --layers, --simplify, --assay-name, --img-res, …),
    no hard-coded paths, cheap pre-flight slot/counts inspection, per-file manifest CSV,
    --dry-run that works without schard.

> Packaging note. Scripts and tables in this skill carry a .txt suffix on their
> original extension (e.g. .R.txt, .tsv.txt) because the SkillHub upload allowlist
> does not accept .R or .tsv. This is cosmetic: Rscript is extension-agnostic, so
> Rscript scripts/&lt;name&gt;.R.txt ... behaves exactly like .R, and tab-separated data
> parses identically from .tsv.txt. Keep the suffix when repackaging.

常见问题

5 问
答案由本站依据条目字段整理
schard h5ad 转换怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_7ece4fea/schard-h5ad-conversion。安装方式为未标注。装完刷新技能列表或重开客户端。

schard h5ad 转换支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

schard h5ad 转换权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

schard h5ad 转换收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

schard h5ad 转换用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。