gravatar for azh7018

2 hours ago by

I don't know if it is even possible. But I assume it should be. I will highly appreciate any help since I am very new.

counts is an S4 object I got from an online course I am doing for microbiome analysis.

 str(counts) Formal class 'dgCMatrix' [package "Matrix"] with 6 slots  
 [email protected] i       : int [1:10483] 4 12 18 19 23 36 44 64 76 77 ...   [email protected] p  
 : int [1:156] 0 59 144 229 289 368 416 462 552 625 ...   [email protected] Dim     :
 int [1:2] 201 155   [email protected] 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" ... 
 [email protected] x       : num [1:10483] 0.0001 0.0099 0.0077 0.0005 0.3367 ...  
 [email protected] factors : list()

This is the structure and you can see the slots are of variable length. I would like to have a data frame with the Bacteria names as my rows which is under [email protected][[1]] and the [email protected][[2]] as my columns. And the values which are in [email protected] into the respective locations which I can see if I simply print counts which looks something like this.

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

Thanks in advance!



Source link