• write10xCounts写入10x格式的h5文件


    转自:https://rdrr.io/github/MarioniLab/DropletUtils/man/write10xCounts.html

    1.安装

    if (!requireNamespace("BiocManager", quietly = TRUE))
        install.packages("BiocManager")
    BiocManager::install("DropletUtils")
    library(DropletUtils)

    2.write10xCounts

    write10xCounts(
      path,
      x,
      barcodes = colnames(x),
      gene.id = rownames(x),
      gene.symbol = gene.id,
      gene.type = "Gene Expression",
      overwrite = FALSE,
      type = c("auto", "sparse", "HDF5"),
      genome = "unknown",
      version = c("2", "3"),
      chemistry = "Single Cell 3' v3",
      original.gem.groups = 1L,
      library.ids = "custom"
    )

    3.多组学数据

    参考代码:

    library(DropletUtils)
    rna=read.table(path1,header=T,sep='	',row.names=1)
    rna_matrix=as.matrix(rna)
    dim(rna_matrix)
    
    atac=read.table(path2,header=T,sep='	',row.names=1)
    atac_matrix=as.matrix(atac)
    dim(atac_matrix)
    
    
    ar=data.frame(rna,atac)#1047 1000
    ar=t(ar)
    write10xCounts(
      'ra.h5',
      ar,
      barcodes = colnames(ar),
      gene.id = rownames(ar),
      gene.symbol = rownames(ar),
      gene.type = c(rep("Gene Expression",500),rep("Peaks",500)),
      overwrite = FALSE,
      type = "HDF5",
      genome = "GRCh38",
      version = "3",
      chemistry = "Single Cell 3' v3",
      original.gem.groups = 1L,
      library.ids = "custom"
    )

    在python中读取可以通过

    re=sc.read_10x_h5('./ra.h5', gex_only=False)

    4.注意 

    https://www.jianshu.com/p/eae2359f6eb1

    需要设置

    check.names=F

    因为R会自动地检测列名,将ATAC的peak特征格式  染色体:start-end,将符号都会改为点.,所以需要上述参数来控制。

  • 相关阅读:
    Ubuntu 上安装MySql
    Vue中组件的使用
    Swagger在 NETcore 中的使用
    awk 中 fieldwidths使用方法
    3.BIND从服务器及缓存服务器配置
    2.BIND服务基础及域主服务器配置
    1.DNS基础及域名系统架构
    Linux防火墙iptables的策略
    inode占用100%时硬盘无法写入文件故障处理
    特殊计算方式(数组)
  • 原文地址:https://www.cnblogs.com/BlueBlueSea/p/15191340.html
Copyright © 2020-2023  润新知