s4 - S4 对象数据提取
问题描述
我不知道这是否可能。但我认为它应该是。我非常感谢任何帮助,因为我很新。
counts 是我从我正在为微生物组分析做的在线课程中获得的一个 S4 对象。
enter code here>
str(counts)
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:10483] 4 12 18 19 23 36 44 64 76 77 ...
..@ p : int [1:156] 0 59 144 229 289 368 416 462 552 625 ...
..@ Dim : int [1:2] 201 155
..@ Dimnames:List of 2
.. ..$ : chr [1:201] "Methanobrevibacter_smithii" "Methanosphaera_stadtmanae" "Rothia_mucilaginosa" "Propionibacterium_freudenreichii" ...
.. ..$ : chr [1:155] "PRISM.7122" "PRISM.7147" "PRISM.7150" "PRISM.7153" ...
..@ x : num [1:10483] 0.0001 0.0099 0.0077 0.0005 0.3367 ...
..@ factors : list()
这是结构,您可以看到插槽的长度可变。我想要一个数据框,其中细菌名称作为我的行,在 counts@Dimnames[[1]] 和 counts@Dimnames[[2]] 作为我的列。如果我只是打印看起来像这样的计数,我可以看到 counts@x 中的值到相应的位置。
Methanobrevibacter_smithii . . . . . . . . . .
Methanosphaera_stadtmanae . . . . . . . . . .
Rothia_mucilaginosa . 9.4e-06 . . . . 5e-04 1.0e-04 1e-04 .
Propionibacterium_freudenreichii . . 0.0018 . . . . . . .
Bifidobacterium_adolescentis 1e-04 . 0.0403 1e-04 . 1e-04 . . . 1e-04
提前致谢!
解决方案
推荐阅读
- mysql - 在垂直表中将数据从一个表更新到另一个表
- mysql - 使用 Spring Boot 在 MySQL 上创建表时如何设置级联删除?
- python - 在for循环python中迭代两个对象
- python - UpdateView 定义主键
- reactjs - React hook 如何访问闭包变量
- javascript - 如何确定是否调用了突变?
- python - 当我已经在虚拟环境中使用 django 运行 API 端点时,如何部署 tabpy 代码?
- python - 一个while循环向上和向下计数
- python - pyinstaller 说“未能执行脚本 gui”
- c# - WCF客户端asp.net core3.1中的XML响应解析异常