Using Perseus data in R

PerseusR Team

2018-11-05

PerseusR provides an interface to use perseus data in R and vice versa

Reading Perseus data in R

As a list

The most basic way to import data from perseus into r is as a list whose elements can then be used in any sort of workflow.

As a MatrixData object

The custom MatrixData object is the most faithfull representation of a perseus matrix in R and is an internal class used by this package to validate whether the fields will be compatible with perseus in additional workflows.

The data matrix object contains the slots that are supported by perseus and can be accessed by the methods of the object (not all of them must be present)

As an expressionSet object (for bioconductor usage)

If you feel more confortable with the bioconductor expression set class, you can also import the data as such.

require(Biobase)
#> Loading required package: Biobase
#> Loading required package: BiocGenerics
#> Loading required package: parallel
#> 
#> Attaching package: 'BiocGenerics'
#> The following objects are masked from 'package:parallel':
#> 
#>     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
#>     clusterExport, clusterMap, parApply, parCapply, parLapply,
#>     parLapplyLB, parRapply, parSapply, parSapplyLB
#> The following objects are masked from 'package:stats':
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from 'package:base':
#> 
#>     Filter, Find, Map, Position, Reduce, anyDuplicated, append,
#>     as.data.frame, basename, cbind, colMeans, colSums, colnames,
#>     dirname, do.call, duplicated, eval, evalq, get, grep, grepl,
#>     intersect, is.unsorted, lapply, lengths, mapply, match, mget,
#>     order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind,
#>     rowMeans, rowSums, rownames, sapply, setdiff, sort, table,
#>     tapply, union, unique, unsplit, which, which.max, which.min
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> 
#> Attaching package: 'Biobase'
#> The following objects are masked from 'package:PerseusR':
#> 
#>     description, description<-
eSet_out <- read.perseus.as.ExpressionSet(dataFile)
class(eSet_out)
#> [1] "ExpressionSet"
#> attr(,"package")
#> [1] "Biobase"
print(eSet_out)
#> ExpressionSet (storageMode: lockedEnvironment)
#> assayData: 5 features, 3 samples 
#>   element names: exprs 
#> protocolData: none
#> phenoData
#>   sampleNames: Column_1 Column_2 Column_3
#>   varLabels: Grouping
#>   varMetadata: labelDescription
#> featureData
#>   featureNames: Row.1 Row.2 ... Row.5 (5 total)
#>   fvarLabels: GO_Process Name
#>   fvarMetadata: labelDescription
#> experimentData: use 'experimentData(object)'
#> Annotation:     Name

eSet_out@annotation
#> [1] ""     ""     ""     ""     "Name"

and the equivalentes with the perseus functions would go like this:

  1. The exprs slot in the expressionSet objects would be equivalent to the main data frame in perseus.
  2. The featureData would be equivalent to the annotationCols.
  3. The phenoData would be aquivalent to the annotationRows.
  4. The Annotation would be equivalent to the descr.

Checking Data compatibility in R

There are a series of functions that check the compatibility R objects with perseus.

MatrixData

This function would not provide much insight on this kind of object because it is run when constructing it; Therefore if the data is not compatible it would return an error when trying to create it

lists

In this case this functions would be usefull, since the object is not inherently compatible.

expressionSet objects

Single matrix Expression Sets will usually be compatible, since most of the restriction in matrix data objects also apply to expression set objects (regarding the dimensions and classes of the objects in each of the slots)

Writting Data into Perseus-compatible text representations

This is the way in which perseus will read the data again so here are a couple of examples.

MatrixData

data.frame

Data frames are converted in such manner that numeric columns are transfered as the main DF and non numerics as the annotation cols of the perseus DF

matrix

Numeric matrices can be outputed as well :D

list

Lists are a little trickier, currently it looks for named elements that match the arguments, so it would use the elements named: main annotCols annotRows and descr

expressionSet objects

Adding elements to the output

Since not all data typer support allthe elements, one can specify them to the function and they will be passed over to the output.

Removing elements form the output

Elements can be set to NULL to remove that section from the output