predict: Do predictions using a fitted MOFA model

Description Usage Arguments Details Value Examples

View source: R/predict.R

Description

This function uses the factors and the corresponding weights to do data predictions.

Usage

1
2
predict(object, views = "all", factors = "all", type = c("inRange",
  "response", "link"))

Arguments

object

a MOFAmodel object.

views

character vector with the view name(s), or numeric vector with the view index(es). Default is "all".

factors

character vector with the factor name(s) or numeric vector with the factor index(es). Default is "all".

type

type of prediction returned, either:

  • response: gives the response vector, the mean for Gaussian and Poisson, and success probabilities for Bernoulli.

  • link: gives the linear predictions.

  • inRange: rounds the fitted values of integer-valued distributions (Poisson and Bernoulli) to the next integer. This is the default option.

Details

Matrix factorization models generate a denoised and condensed low-dimensional representation of the data which capture the main sources of heterogeneity of the data. Such representation can be used to do predictions (data reconstruction) and imputation (see impute).
For mathematical details, see the Methods section of the MOFA article.

Value

Returns a list with data predictions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library(ggplot2)

# Example on the CLL data
filepath <- system.file("extdata", "CLL_model.hdf5", package = "MOFAdata")
MOFA_CLL <- loadModel(filepath)

# predict drug response data using all factors
predictedDrugs <- predict(MOFA_CLL, view="Drugs")

# predict all views using all factors (default)
predictedAll <- predict(MOFA_CLL)

# predict Mutation data using all factors, returning Bernoulli probabilities
predictedMutations <- predict(MOFA_CLL, view="Mutations", type="response")

# predict Mutation data using all factors, returning binary classes
predictedMutationsBinary <- predict(MOFA_CLL, view="Mutations", type="inRange")

# Compare the predictions with the true data
pred <- as.numeric(predictedAll$Drugs)
true <- as.numeric(getTrainData(MOFA_CLL)$Drugs)
qplot(pred,true) + geom_hex(bins=100) + coord_equal() + 
   geom_abline(intercept=0, slope=1, col="red")

# Example on the scMT data
filepath <- system.file("extdata", "scMT_model.hdf5", package = "MOFAdata")
MOFA_scMT <- loadModel(filepath)

# Predict all views using all factors (default)
predictedAll <- predict(MOFA_scMT)
 
# Compare the predictions with the true data
view <- "RNA expression"
pred <- as.numeric(predictedAll[[view]])
true <- as.numeric(getTrainData(MOFA_scMT)[[view]])
qplot(pred,true) + geom_hex(bins=100) + coord_equal() + 
   geom_abline(intercept=0, slope=1, col="red") 

MOFA documentation built on Feb. 11, 2021, 2:01 a.m.