rformassspectrometry / QFeatures

Quantitative features for mass spectrometry data
https://RforMassSpectrometry.github.io/QFeatures/
25 stars 7 forks source link

longFormat for SE with rowvars #196

Open lgatto opened 1 year ago

lgatto commented 1 year ago
> class(x)
[1] "SummarizedExperiment"
attr(,"package")
[1] "SummarizedExperiment"
> qf <- QFeatures(list(x = x))

longFormat() works for for QFeatures with and without rowvars:

> head(longFormat(qf))
DataFrame with 6 rows and 5 columns
        assay       primary     rowname       colname     value
  <character>   <character> <character>   <character> <numeric>
1           x control_at...           1 control_at...        NA
2           x control_at...           2 control_at...   20.2415
3           x control_at...           3 control_at...   18.8851
4           x control_at...           4 control_at...   18.1608
5           x control_at...           5 control_at...   19.1839
6           x control_at...           6 control_at...   15.6747
> head(longFormat(qf, rowvars = "nNA"))
DataFrame with 6 rows and 6 columns
        assay       primary     rowname       colname     value       nNA
  <character>   <character> <character>   <character> <numeric> <integer>
1           x control_at...           1 control_at...        NA         5
2           x control_at...           2 control_at...   20.2415         0
3           x control_at...           3 control_at...   18.8851         0
4           x control_at...           4 control_at...   18.1608         2
5           x control_at...           5 control_at...   19.1839         0
6           x control_at...           6 control_at...   15.6747         1

longFormat() works for an SE only without rowvars:

> head(longFormat(x))
  rowname      colname    value
1       1 control_atcc       NA
2       2 control_atcc 20.24148
3       3 control_atcc 18.88513
4       4 control_atcc 18.16084
5       5 control_atcc 19.18385
6       6 control_atcc 15.67467
> head(longFormat(x, rowvars = "nNA"))
Error in (function (cond)  : 
  error in evaluating the argument 'x' in selecting a method for function 'head': inherits(x, "MultiAssayExperiment") is not TRUE
lgatto commented 11 months ago

Or switch to tidySummarizedExperiment and tidySingleCellExperiment.