Summary and relative abundance
MoemenEltobgy opened this issue · 3 comments
I am trying to have some summary stats for all my analytes and also summary for them after grouping according to gender or mortality. I do not know how to use SomaDataIO to do that so I used it in combination with diplyr package.
I have ran into an error while trying to save my summary files and export them as CSV.
Now my questions are:
- what is the proper way to do these summary stuff I mentioned? if the way i used is valid, then how can i correct this error and export the files?
- I want also have some relative abundance for all my data and then for the groups I created. If anyone knows how to get this done, it would be a great help.
thanks
Please describe your question with R code if appropriate:
#summ.1<-getAnalytes(my_adat.1)
> summ.gender<-my_adat.1[, summ.1] %>%
+ split(my_adat.1$demo_sex) %>%
+ lapply(summary)
> summ.alive<-my_adat.1[, summ.1] %>%
+ split(my_adat.1$Alive) %>%
+ lapply(summary)
> summ.all<-my_adat.1[, summ.1] %>%
+ lapply(summary)
> write_csv(summ.gender, file = "~/Documents/summarygender.csv")
Error in write_delim(x, file, delim = ",", na = na, append = append, col_names = col_names, :
is.data.frame(x) is not TRUE
> typeof(summ.alive)
[1] "list"
> is.data.frame(summ.alive)
[1] FALSE
Priority Level
- High
Thanks for using SomaDataIO!
We have a summary()
method for the soma_adat
class that will summarize as you describe.
Please see the ?summary.soma_adat
help page (and examples therein).
To export the output of the summary()
generic, see ?sink
or ?dput
.
In addition, the example you proved will fail on another user's machine. It is much easier to help you to a solution if the example you provide is executable. Please see the reprex package along with their do's and don'ts.
For example:
mmps <- c("seq.2579.17", "seq.2788.55", "seq.2789.26", "seq.4925.54")
foo <- example_data[, mmps] |>
split(example_data$Sex) |>
lapply(summary)
foo
sink("foo.txt")
foo
sink(NULL)
Alternatively, if you need the export to be a *.csv
:
lapply(names(foo), function(x) {
write.csv(foo[[x]], file = paste0(x, ".csv"), row.names = FALSE, quote = FALSE)
})
Forwarded on to technical support techsupport@somalogic.com