| Title: | A Package to Find Minimal Transcriptional Signatures |
|---|---|
| Description: | Identifies minimal biomarker signatures for predicting phenotypes from multiomic data. Integrates multiple omics layers, supports internal cross-validation. Supports missing values in predictors and outcomes. Enables model based imputation of uncertain values. Supports continuous, binary, multi-class and ordinal outcomes. |
| Authors: | Lachlan Coin [aut, cre] |
| Maintainer: | Lachlan Coin <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-10-08 11:33:39 UTC |
| Source: | https://github.com/cran/fspls2 |
A class that encapsulates a dataset holder and/or analysis of datasets
Available methods:
new() - Create a new instance
name() - Get dataset name
clone() - Clone the object
analysisBase$new()Create a new instance of base class
analysisBase$new(nme, dims = NULL, flags = list(), dbDir = tempdir())
nmename
dimsdims
flagsa list object specifying options
dbDirlocation for database to be written, default to tempdir
analysisBase$name()get dataset name;
analysisBase$name()
assigned name of dataset
analysisBase$integrate()integrates variables from different CV runs
analysisBase$integrate(variables)
variablesa variables object
analysisBase$clone()The objects of this class are cloneable with this method.
analysisBase$clone(deep = FALSE)
deepWhether to make a deep clone.
A class that encapsulates analysis of one or more datasets. Only expert users wlil need access to this
Available methods:
new() - Create a new instance
name() - Get dataset name
clone() - Clone the object
@export
analysisBase -> analysisEnv
analysisEnv$new()Create a new instance
analysisEnv$new(flags = list(), dbDir = tempdir())
flagsa list object specifying options
dbDirlocation for database to be written. If NULL then no DB gets the trajectory
analysisEnv$plot_trajectory()analysisEnv$plot_trajectory(datasH)
datasHa list of dataH objects after variable selection selection for a single fold
analysisEnv$select_k()analysisEnv$select_k(datasH, k1, vars_l_todo)
datasHa list of dataH objects
k1the fold
vars_l_todoan object representing what is left to do
vars_l_todo object Get todo
analysisEnv$getTodo()analysisEnv$getTodo(flags, phens)
flagslist of options
phensphenotypes
object outlining what is left to do for next iteration Clear the databases. Only necessary if using a database and re-running analyses
analysisEnv$clear_db()analysisEnv$clear_db(drop = FALSE, exclude = "vars", datasH = NULL)
dropcompletely drop tables and start from scratch
excludetables to exclue from clearing
datasHlist of dataH objects to clear Get the next vars in iteration. Internal function
analysisEnv$savePvalsAndNextVars()analysisEnv$savePvalsAndNextVars(vars_l_todo, comb2_new, data_nme, k1)
vars_l_todovars_l_todo
comb2_newresults
data_nmename of dataset
k1which repetition
object outlining what is left to do main function for variable selection
analysisEnv$select()analysisEnv$select( datasH, phens, transform_x, data_types = datasH[[1]]$data_types() )
datasHa list of dataH objects
phenslist of phenotypes
transform_xtransformation object
data_typesdata_types object
analysisEnv$clone()The objects of this class are cloneable with this method.
analysisEnv$clone(deep = FALSE)
deepWhether to make a deep clone.
A class that encapsulates a dataset holder
Available methods:
new() - Create a new instance
name() - Get dataset name
clone() - Clone the object
analysisBase -> dataH
dataH$new()Create a new instance
dataH$new( data, y, certainty = rep(1, nrow(y)), nme, flags, family = getFamily(y), dbDir = NULL )
dataa list of matrices (of different modalities), with columns as variables and rows as samples
yphenotype matrix, with columns as outcomes and rows as samples
certaintythe certainty of each observation, expressed as a probability of being correct. Default is to treat each observation as certain
nmeThe name of the data objetct.
flagslist of options, described in the vignette
familythe statistical family of phenotype y, can be calculated by getFamily
dbDirdir for database to store results to speed up re-reruns. Can be NULL
transform_xa transformation object from the function getTransformation
dataH$multiAnglesAndPv()Calculate the angles and pv across multiple phenotypes. This is an internal function and should not need to be called by user
dataH$multiAnglesAndPv(comb20, k1, expt_id, vars_l_todo)
comb20values from previous iteration
k1k1 is the current fold
expt_idand ID for the experiment (can be 0)
vars_l_todothe variables under consideration clear database. This is only used if you want to clear the database. Internal function
phens1phenotypes being used
flagslist of options
dataH$clear_db()dataH$clear_db(drop = FALSE, exclude = "vars")
dropdrop the tables instead of clear
excludewhich tables not to clear
dataH$get_trajectory()returns data on trajectory
dataH$get_trajectory()
a dataframe with information to plot trajectory get the data types
dataH$data_types()dataH$data_types( data_nmes = list(all = names(private$data$data)), inds = lapply(data_nmes, function(x) list(pos_inds = c(), neg_inds = c(), max = 1000)), direction = lapply(inds, private$data$getDirection), incl = c(), excl = c() )
data_nmesa list of names of the data names to include, optional
indsa list of positive and negative inds, optional
directiona direction object
incla list of variables to include
excla list of variables to exclude
an object which is used to specify both directionallity and data types
dataH$split()split dataset into smaller datasets
dataH$split(proportions = c(0.5, 0.5))
proportionswhat proportions to split into
a list of dataH objects with data partiioned according to proportions
dataH$pheno()get the phenotyeps
dataH$pheno()
phenotypes
dataH$dims()get the dimensions
dataH$dims()
dimensions get the nreps
dataH$nreps()dataH$nreps()
nreps
dataH$update()update the phenotypes without remaking the entire object. You can provide many phenotypes in the initialisation stage, but only consider a subset in model fitting stage in this way.Must run this before select
dataH$update( phens = self$pheno()$all, flags = private$flags, transform_x = fromJSON(flags$transform_x), data_types = self$data_types() )
phensphenotypes
flagslist of options
transform_xtransformation object
data_typesa data_type object
dataH$select()main function for variable selection
dataH$select(analysis = analysisEnv$new(flags = private$flags, dbDir = NULL))
analysisan analysisEnv object
dataH$y()provides access to internal storage of phenotype data
dataH$y(phens = self$pheno()[[1]])
phenslist of phenotypes
list of matrices
dataH$plotPredictions()ggplot to visualise predictions
dataH$plotPredictions(all_modelsh, update = FALSE, liab = TRUE)
all_modelshfitted models from makeAllModels
updatewhether to update
liabreturn liability score, or probability (for binomial, ordinal multinomial)
a ggplot
dataH$extractPredictions()extract the predictions for the fitted models
dataH$extractPredictions(all_modelsh, liab = TRUE)
all_modelshfitted models from makeAllModels
liabreturn liability score, or probability (for binomial, ordinal multinomial)
a table with results
dataH$plotData()plot all data for selected variables
dataH$plotData( variables, all_types = FALSE, violin = FALSE, assoc = FALSE, update = FALSE )
variablesobject returned by fspls.select
all_typesuse all types?
violinviolin plots
assocuse association
updatewhether to use attributes from bariables to update this object, default is FALSE
a table with results
dataH$updateWeights()update the weights based on predictions from the model
dataH$updateWeights(all_models)
all_modelsthe output of dataH function getAllModels
list of auc beta and updated sumdiff of weights used as stopping criteria
dataH$getYNew()return updated y after iterative imputation
dataH$getYNew()
updated y, updated certainty and indices which were updated
dataH$getProjectedData()get data after projection
dataH$getProjectedData(varnames)
varnamesvarnames
projected data after projecting out varnames
dataH$getVariance()get variance of data
dataH$getVariance(varnames)
varnamesvarnames
variance
dataH$makeAllModels()fit models based on variables
dataH$makeAllModels(variables, update = FALSE)
variableslist of variables selected by select method
updatewhether to automatically update phens, transform_x and flags , default TRUE
fitted models
dataH$evaluateAllModels()evaluate the fit of models
dataH$evaluateAllModels(all_modelsh, update = TRUE)
all_modelshmodels fitted from makeAllModels
updatewhether to automatically update phens, transform_x and flags , default TRUE
evaluation of models
dataH$clone()The objects of this class are cloneable with this method.
dataH$clone(deep = FALSE)
deepWhether to make a deep clone.
main function for variable selection with unknown values
fspls.iterative(dataset, flags, transform_x)fspls.iterative(dataset, flags, transform_x)
dataset |
a list with y and data value |
flags |
list of options |
transform_x |
transformation object |
main function for variable selection
fspls.select( datasH, flags, transform_x, phens = datasH[[1]]$pheno()$all, data_types = datasH[[1]]$data_types(), dbDir = NULL )fspls.select( datasH, flags, transform_x, phens = datasH[[1]]$pheno()$all, data_types = datasH[[1]]$data_types(), dbDir = NULL )
datasH |
a list of dataH objects |
flags |
list of options |
transform_x |
transformation object |
phens |
list of phenotypes |
data_types |
a data type object |
dbDir |
database dir, can be NULL |
Infer the statistical families of the phenotypes
getFamily(y_mat, max_ordinal = getOption("max_ordinal", 10))getFamily(y_mat, max_ordinal = getOption("max_ordinal", 10))
y_mat |
a matrix of phenotypes, with columns as variables and rows as samples |
max_ordinal |
maximum number of values before we consider an ordinal value as a continuous value |
a list with the statistical families detected
extracts the full model variables from a cross validation run
getFolds(leng, nrep = NA, batch = NA, randomize = TRUE)getFolds(leng, nrep = NA, batch = NA, randomize = TRUE)
leng |
length of dataset |
nrep |
number of reps |
batch |
batch size (one of batch or nrep is non NA) |
randomize |
whether to randomize |
Get object for transforming the x variables
getTransform( pows = c(1), offset = 0, n_random = 1, perm = FALSE, norm = 1, CHECK = FALSE )getTransform( pows = c(1), offset = 0, n_random = 1, perm = FALSE, norm = 1, CHECK = FALSE )
pows |
power to raise to |
offset |
offset to subtract |
n_random |
how many random variables |
perm |
whether random is permutation |
norm |
rescaling factor |
CHECK |
check whether inverse function works |
transformation object
Plot the results from evaluateAll
plotEval( eval3, shape_color = c("pheno", "subpheno"), shape = shape_color, text = "variable", dotsize = "nsamps", color = shape_color, linetype = shape, showranges = TRUE, txtsize = 1, logy = FALSE, legend = FALSE, sep_by = "", scales = "free", point = TRUE, line = TRUE, labelsize = 2, grid0 = c("cohort", "measure"), grid1 = "cv_full", title = "", title1 = "" )plotEval( eval3, shape_color = c("pheno", "subpheno"), shape = shape_color, text = "variable", dotsize = "nsamps", color = shape_color, linetype = shape, showranges = TRUE, txtsize = 1, logy = FALSE, legend = FALSE, sep_by = "", scales = "free", point = TRUE, line = TRUE, labelsize = 2, grid0 = c("cohort", "measure"), grid1 = "cv_full", title = "", title1 = "" )
eval3 |
a tibble or data frame from evaluateAll method from dataH |
shape_color |
a list of column names to encode as both shape and color |
shape |
defaults to shape_color but can be specified separately |
text |
a list of column names to include as text labels |
dotsize |
a numerical column to encode dotsize, or a number for constant sizes |
color |
defaults to shape_color but can be specified separately |
linetype |
column controlling the type of line |
showranges |
whether to show 95% CI as ribbon |
txtsize |
size of text |
logy |
whether to log y axis |
legend |
whether to show a legend |
sep_by |
list of column names to separate into diff plots |
scales |
used in faceting can be free or fixed |
point |
whether to show dots |
line |
whether to include line |
labelsize |
the size of the text labels |
grid0 |
how to facet on y |
grid1 |
how to facet on x |
title |
the title |
title1 |
columns to include in the title |
ggplot2 plot