【问题标题】:Getting only the rownames containing a specific character - R仅获取包含特定字符的行名 - R
【发布时间】:2019-07-19 09:23:02
【问题描述】:

我有一个 Seurat R 对象。我只想选择与特定样本对应的数据。因此,我只想获取包含特定字符的行名。我的行名差异示例:CTAAGCTT-1 和 CGTAAAT-2。我想根据 1 和 2 进行区分。下面的代码显示了我已经尝试过的内容。但它只返回总行数。不是有多少行与字符匹配。

length <- length(rownames(seuratObject@meta.data) %in% "1")

length <- length(grepl("-1",rownames(seuratObj@meta.data)))
Idents(seuratObject, cells = 1:length)

感谢您的任何意见。

【问题讨论】:

  • 您可能想使用greplgreplength(grep("1$", rownames(seuratObject@meta.data)))sum(grepl("1$", rownames(seuratObject@meta.data)))

标签: r pattern-matching row seurat


【解决方案1】:

只是缺少which()

length(which(grepl("-1", rownames(seuratObject@meta.data))))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 2017-08-02
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    相关资源
    最近更新 更多