Convenience accessor to the predicted feature localisation in an 'MSnSet'.
This function returns the predictions of an
MSnSet
instance. As a side effect, it prints out a prediction table.
Arguments
- object
An instance of class
"MSnSet"
.- fcol
The name of the prediction column in the
featureData
slot.- scol
The name of the prediction score column in the
featureData
slot. If missing, created by pasting '.scores' afterfcol
.- mcol
The feature meta data column containing the labelled training data.
- t
The score threshold. Predictions with score < t are set to 'unknown'. Default is 0. It is also possible to define thresholds for each prediction class, in which case,
t
is a named numeric with names exactly matching the unique prediction class names.- verbose
If
TRUE
, a prediction table is printed and the predictions are returned invisibly. IfFALSE
, the predictions are returned.
Value
An instance of class "MSnSet" with fcol.pred
feature
variable storing the prediction results according to the chosen threshold.
See also
orgQuants
for calculating organelle-specific
thresholds.
Examples
library("pRolocdata")
data(dunkley2006)
res <- svmClassification(dunkley2006, fcol = "pd.markers",
sigma = 0.1, cost = 0.5)
#> [1] "pd.markers"
fData(res)$svm[500:510]
#> [1] Plastid Plastid ER membrane Ribosome Ribosome Ribosome
#> [7] Ribosome Ribosome Ribosome Ribosome Ribosome
#> 9 Levels: ER lumen ER membrane Golgi Mitochondrion PM Plastid Ribosome ... vacuole
fData(res)$svm.scores[500:510]
#> [1] 0.6593303 0.7701427 0.6752305 0.4882591 0.5751725 0.5766412 0.6376513
#> [8] 0.6215169 0.5313678 0.6123313 0.6602089
getPredictions(res, fcol = "svm", t = 0) ## all predictions
#> ans
#> ER lumen ER membrane Golgi Mitochondrion PM
#> 16 188 101 101 125
#> Plastid Ribosome TGN vacuole
#> 52 59 17 30
#> MSnSet (storageMode: lockedEnvironment)
#> assayData: 689 features, 16 samples
#> element names: exprs
#> protocolData: none
#> phenoData
#> sampleNames: M1F1A M1F4A ... M2F11B (16 total)
#> varLabels: membrane.prep fraction replicate
#> varMetadata: labelDescription
#> featureData
#> featureNames: AT1G09210 AT1G21750 ... AT4G39080 (689 total)
#> fvarLabels: assigned evidence ... svm.pred (11 total)
#> fvarMetadata: labelDescription
#> experimentData: use 'experimentData(object)'
#> pubMedIds: 16618929
#> Annotation:
#> - - - Processing information - - -
#> Loaded on Thu Jul 16 22:53:08 2015.
#> Normalised to sum of intensities.
#> Added markers from 'mrk' marker vector. Thu Jul 16 22:53:08 2015
#> Performed svm prediction (cost=0.5 sigma=0.1) Sat Nov 23 16:03:53 2024
#> Added svm predictions according to global threshold = 0 Sat Nov 23 16:03:53 2024
#> MSnbase version: 1.17.12
getPredictions(res, fcol = "svm", t = .9) ## single threshold
#> ans
#> ER lumen ER membrane Golgi Mitochondrion PM
#> 14 56 28 55 46
#> Plastid Ribosome TGN unknown vacuole
#> 20 19 13 417 21
#> MSnSet (storageMode: lockedEnvironment)
#> assayData: 689 features, 16 samples
#> element names: exprs
#> protocolData: none
#> phenoData
#> sampleNames: M1F1A M1F4A ... M2F11B (16 total)
#> varLabels: membrane.prep fraction replicate
#> varMetadata: labelDescription
#> featureData
#> featureNames: AT1G09210 AT1G21750 ... AT4G39080 (689 total)
#> fvarLabels: assigned evidence ... svm.pred (11 total)
#> fvarMetadata: labelDescription
#> experimentData: use 'experimentData(object)'
#> pubMedIds: 16618929
#> Annotation:
#> - - - Processing information - - -
#> Loaded on Thu Jul 16 22:53:08 2015.
#> Normalised to sum of intensities.
#> Added markers from 'mrk' marker vector. Thu Jul 16 22:53:08 2015
#> Performed svm prediction (cost=0.5 sigma=0.1) Sat Nov 23 16:03:53 2024
#> Added svm predictions according to global threshold = 0.9 Sat Nov 23 16:03:53 2024
#> MSnbase version: 1.17.12
## 50% top predictions per class
ts <- orgQuants(res, fcol = "svm", t = .5)
#> ER lumen ER membrane Golgi Mitochondrion PM
#> 0.2995766 0.8368847 0.7805362 0.7484314 0.7302249
#> Plastid Ribosome TGN vacuole
#> 0.7746137 0.5428105 0.5276547 0.5704931
getPredictions(res, fcol = "svm", t = ts)
#> ans
#> ER lumen ER membrane Golgi Mitochondrion PM
#> 15 117 65 78 86
#> Plastid Ribosome TGN unknown vacuole
#> 36 39 15 212 26
#> MSnSet (storageMode: lockedEnvironment)
#> assayData: 689 features, 16 samples
#> element names: exprs
#> protocolData: none
#> phenoData
#> sampleNames: M1F1A M1F4A ... M2F11B (16 total)
#> varLabels: membrane.prep fraction replicate
#> varMetadata: labelDescription
#> featureData
#> featureNames: AT1G09210 AT1G21750 ... AT4G39080 (689 total)
#> fvarLabels: assigned evidence ... svm.pred (11 total)
#> fvarMetadata: labelDescription
#> experimentData: use 'experimentData(object)'
#> pubMedIds: 16618929
#> Annotation:
#> - - - Processing information - - -
#> Loaded on Thu Jul 16 22:53:08 2015.
#> Normalised to sum of intensities.
#> Added markers from 'mrk' marker vector. Thu Jul 16 22:53:08 2015
#> Performed svm prediction (cost=0.5 sigma=0.1) Sat Nov 23 16:03:53 2024
#> Added svm predictions according to thresholds: ER lumen = 0.30, ER membrane = 0.84, Golgi = 0.78, Mitochondrion = 0.75, PM = 0.73, Plastid = 0.77, Ribosome = 0.54, TGN = 0.53, vacuole = 0.57 Sat Nov 23 16:03:53 2024
#> MSnbase version: 1.17.12