r - R中的脚本越界
问题描述
我正在使用基于 Deseq2 的代码。我的目标之一是绘制数据热图。
heatmap.data <- counts(dds)[topGenes,]
我得到的错误是
计数错误(dds)[topGenes,]:下标超出范围
我的 counts(dds) 函数的前几行如下所示。
99h1 99h2 99h3 99h4 wth1 wth2
ENSDARG00000000002 243 196 187 117 91 96
ENSDARG00000000018 42 55 53 32 48 48
ENSDARG00000000019 91 91 108 64 95 94
ENSDARG00000000068 3 10 10 10 30 21
ENSDARG00000000069 55 47 43 53 51 30
ENSDARG00000000086 46 26 36 18 37 29
ENSDARG00000000103 301 289 289 199 347 386
ENSDARG00000000151 18 19 17 14 22 19
ENSDARG00000000161 16 17 9 19 10 20
ENSDARG00000000175 10 9 10 6 16 12
ENSDARG00000000183 12 8 15 11 8 9
ENSDARG00000000189 16 17 13 10 13 21
ENSDARG00000000212 227 208 259 234 78 69
ENSDARG00000000229 68 72 95 44 71 64
ENSDARG00000000241 71 92 67 76 88 74
ENSDARG00000000324 11 9 6 2 8 9
ENSDARG00000000370 12 5 7 8 0 5
ENSDARG00000000394 390 356 339 283 313 286
ENSDARG00000000423 0 0 2 2 7 1
ENSDARG00000000442 1 1 0 0 1 1
ENSDARG00000000472 16 8 3 5 7 8
ENSDARG00000000476 2 1 2 4 6 3
ENSDARG00000000489 221 203 169 144 84 114
ENSDARG00000000503 133 118 139 89 91 112
ENSDARG00000000529 31 25 17 26 15 24
ENSDARG00000000540 25 17 17 10 28 19
ENSDARG00000000542 15 9 9 6 15 12
我如何确保顶级基因的所有元素都存在于其中?当我尝试查看数据集中的 20 个顶级基因时。它看起来像一个基因列表
6339" "12416" "1241" "3025" "12791" "846" "15090"
[8] "6529" "14564" "4863" "12777" "1122" "7454" "13716"
[15] "5790" "3328" "1231" "13734" "2797" "9072" with the column head V1.
我都用过
topGenes <- read.table("E://mir99h50 Cheng data//topGenesresordered.txt",header = TRUE)
和
topGenes <- read.table("E://mir99h50 Cheng data//topGenesresordered.txt",header = FALSE)
查看是否删除了越界错误。然而这并没有什么用。我猜是V1头导致了这个问题。使用上面的代码片段生成了顶级基因函数。
resordered <- res[order(res$padj),]
#Reorder gene list by increasing pAdj
resordered <- as.data.frame(res[order(res$padj),])
#Filter for genes that are differentially expressed with an FDR < 0.01
ii <- which(res$padj < 0.01)
length(ii)
# Use the rownames() function to get the top 20 differentially expressed genes from our results table
topGenes <- rownames(resordered[1:20,])
topGenes
# Get the counts from the DESeqDataSet using the counts() function
heatmap.data <- counts(dds)[topGenes,]
解决方案
也许这会做你想要的?
counts_dds <- counts(dds)
topgenes <- c("ENSDARG00000000002", "ENSDARG00000000489", "ENSDARG00000000503",
"ENSDARG00000000540", "ENSDARG00000000529", "ENSDARG00000000542")
heatmap.data <- counts_dds[rownames(counts_dds) %in% topgenes,]
如果您提供更多信息,将更容易就如何解决您的问题向您提供建议。
推荐阅读
- git - Git重置后头部仍然分离 - 很难
- apollo-server - typedef 中定义的注释未出现在 Apollo Server 2.0 Playground UI 中
- python - 处理不定长度的文本时如何管理列表索引?
- matplotlib - 在 Jupyter Notebook 中使用 PyPlot 作为 Plot.jl 的后端时如何设置 svg 输出
- c# - 在控制器之外使用 LinkGenerator
- laravel - Vue.js Axios 帖子未返回 JSON 格式。我怎样才能在控制器上捕捉到它?
- c# - 登录表单 [RedirectFromLoginPage] 不起作用,母版页
- dart - 转换的纪元时间比模拟器提前 5 小时
- sql-server - 分配给 SQL Server 中表的未使用空间
- sql-server - 循环计数器的 SSIS 增量在 99 后重置为 1