0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

R への .h5Seurat 読み込み時に起きるエラー「'recursive' must be a length-1 vector」の解決策

0
Last updated at Posted at 2025-11-08

最近、KPMP のサイトから scRNA-seq データを引っ張ることがあったのだが、R への .h5Seurat の読み込み時に毎回同じエラーが出たため解決策をメモっておく。※ chatGPT で調べたが解決しなかった。

使用パッケージ
Seurat: 5.3.1
SeuratDisk: 0.0.0.9021

最初の入力コード

# R の例
obj <- LoadH5Seurat(file = "0f95993d-1bbc-427e-8f5c-14ccf630ef26_KPMP_PREMIERE_SC_version1.5_ForExplorer_withRC.032624.h5Seurat")

エラー出力
image.png

debug していったところ、どうも内部で動く as.Seurat 内に問題があるらしい。

if (packageVersion(pkg = "Seurat") >= numeric_version(x = spatial.version)) {
    images <- GetImages(images = images, index = index, 
      assays = assays)
    for (image in images) {
      if (verbose) {
        message("Adding image ", image)
      }
      object[[image]] <- AssembleImage(image = image, 
        file = x, verbose = verbose)
    }
  }

spatial.version がネックで、これが 3.~~~ とかになっている(Seurat の古いバージョン時に作られた?)

解決策は簡単で、LoadH5Seurat 関数に image = list() を付けるだけ。

改善入力コード

# R の例
obj <- LoadH5Seurat(file = "0f95993d-1bbc-427e-8f5c-14ccf630ef26_KPMP_PREMIERE_SC_version1.5_ForExplorer_withRC.032624.h5Seurat", image = list())

これで読み込めた。
Visium とかだとどうなるのかは不明。少なくとも scRNA-seq では Seurat Object の image 内は空のはずなので、これで問題なさそう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?