Class DiffExAnalyzerUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectMatrix<BioMaterial, ExperimentalFactor, Object> buildDesignMatrix(List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, boolean allowMissingValues) Build a design matrix for the given factors and samples.static ObjectMatrix<String, String, Object> buildRDesignMatrix(List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, boolean allowMissingValues) Build an R-friendly design matrix.static ObjectMatrix<String, String, Object> buildRDesignMatrix(List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, Map<ExperimentalFactor, FactorValue> baselines, boolean allowMissingValues) A variant ofbuildRDesignMatrix(List, List, boolean)that allows for reusing baselines for repeated calls.static BioAssayDimensioncreateBADMap(List<BioMaterial> columnsToUse) static ProtocolcreateProtocolForConfig(DifferentialExpressionAnalysisConfig config, Map<ExperimentalFactor, FactorValue> baselineFactorValues) static AnalysisTypedetermineAnalysisType(BioAssaySet bioAssaySet, Collection<ExperimentalFactor> experimentalFactors, ExperimentalFactor subsetFactor, boolean includeInteractionsIfPossible) Determines the analysis to execute based on the experimental factors, factor values, and block design.static AnalysisTypedetermineAnalysisType(BioAssaySet bioAssaySet, Collection<ExperimentalFactor> experimentalFactors, ExperimentalFactor subsetFactor, boolean includeInteractionsIfPossible, Collection<BioMaterial> samplesToAnalyze) A variant that decides from a given set of samples rather than every sample in the experiment.static AnalysisTypedetermineAnalysisType(BioAssaySet bioAssaySet, DifferentialExpressionAnalysisConfig config) static AnalysisTypedetermineAnalysisType(BioAssaySet bioAssaySet, DifferentialExpressionAnalysisConfig config, Collection<BioMaterial> samplesToAnalyze) A variant that decides from a given set of samples rather than every sample in the experiment.static ExpressionDataDoubleMatrixRemove the samples that are not analyzed (seeisAnalyzed(BioMaterial)) from a data matrix.static StringFormat an interaction of factors.static booleanisAnalyzed(BioMaterial sample) Check whether a sample takes part in a differential expression analysis.static DoubleMatrix<String, String> makeDataMatrix(ObjectMatrix<String, String, Object> designMatrix, DoubleMatrix<CompositeSequence, BioMaterial> namedMatrix) Convert the data into a string-keyed matrix.static StringnameForR(BioMaterial sample) Create a name for a sample suitable for R.static Stringstatic StringnameForR(ExperimentalFactor experimentalFactor) Create a name for the factor that is suitable for R.static StringnameForR(FactorValue fv, boolean isBaseline) Create a name for the factor value that is suitable for R.static voidpopulateFactorValues(Collection<BioMaterial> samples, ExperimentalFactor f, Collection<FactorValue> fvs) As above, over a given set of samples rather than every sample of the experiment or subset.static void
-
Field Details
-
BIO_MATERIAL_RNAME_PREFIX
- See Also:
-
FACTOR_RNAME_PREFIX
- See Also:
-
FACTOR_VALUE_RNAME_PREFIX
- See Also:
-
FACTOR_VALUE_BASELINE_SUFFIX
- See Also:
-
-
Constructor Details
-
DiffExAnalyzerUtils
public DiffExAnalyzerUtils()
-
-
Method Details
-
isAnalyzed
Check whether a sample takes part in a differential expression analysis.Two kinds of sample do not: those a curator has marked
DE_Exclude, and those whose assays are all flagged as outliers. Both must be removed before anything is decided from the sample set — baselines, whether a factor is complete, the analysis type and the degrees of freedom are all computed from it. -
dropSamplesNotAnalyzed
Remove the samples that are not analyzed (seeisAnalyzed(BioMaterial)) from a data matrix.The matrix is returned unchanged when there is nothing to drop, which is the common case.
- Throws:
IllegalStateException- if every sample would be dropped
-
createBADMap
-
populateFactorValuesFromBASet
public static void populateFactorValuesFromBASet(BioAssaySet ee, ExperimentalFactor f, Collection<FactorValue> fvs) -
populateFactorValues
public static void populateFactorValues(Collection<BioMaterial> samples, ExperimentalFactor f, Collection<FactorValue> fvs) As above, over a given set of samples rather than every sample of the experiment or subset. Counting levels over the raw set lets a factor whose second level is carried only by an excluded or outlier sample look variable, so it survives into the model as a constant column. -
makeDataMatrix
public static DoubleMatrix<String,String> makeDataMatrix(ObjectMatrix<String, String, Object> designMatrix, DoubleMatrix<CompositeSequence, BioMaterial> namedMatrix) Convert the data into a string-keyed matrix. Assumes that the row names of the designMatrix are concordant with the column names of the namedMatrix -
nameForR
-
determineAnalysisType
public static AnalysisType determineAnalysisType(BioAssaySet bioAssaySet, DifferentialExpressionAnalysisConfig config) - Returns:
- selected type of analysis such as t-test, two-way ANOVA, etc.
-
determineAnalysisType
public static AnalysisType determineAnalysisType(BioAssaySet bioAssaySet, DifferentialExpressionAnalysisConfig config, @Nullable Collection<BioMaterial> samplesToAnalyze) A variant that decides from a given set of samples rather than every sample in the experiment.- Parameters:
samplesToAnalyze- the samples that will actually be modelled, or null to use all of them. Pass the samples left afterdropSamplesNotAnalyzed(ExpressionDataDoubleMatrix), so that DE_Exclude and outlier samples do not decide the analysis type.- Returns:
- selected type of analysis such as t-test, two-way ANOVA, etc.
-
determineAnalysisType
@Nullable public static AnalysisType determineAnalysisType(BioAssaySet bioAssaySet, Collection<ExperimentalFactor> experimentalFactors, @Nullable ExperimentalFactor subsetFactor, boolean includeInteractionsIfPossible) Determines the analysis to execute based on the experimental factors, factor values, and block design.This overload judges from every sample in the experiment. Prefer the variant taking
samplesToAnalyzewhen DE_Exclude or outlier samples may be present — seedropSamplesNotAnalyzed(ExpressionDataDoubleMatrix).- Parameters:
bioAssaySet- experiment or subset to determine the analysis type forexperimentalFactors- which factors to use, or null if to use all from the experimentsubsetFactor- can be nullincludeInteractionsIfPossible- include interactions among the provided experimental factors if possible- Returns:
- an appropriate analysis type
-
determineAnalysisType
public static AnalysisType determineAnalysisType(BioAssaySet bioAssaySet, Collection<ExperimentalFactor> experimentalFactors, @Nullable ExperimentalFactor subsetFactor, boolean includeInteractionsIfPossible, @Nullable Collection<BioMaterial> samplesToAnalyze) A variant that decides from a given set of samples rather than every sample in the experiment.- Parameters:
samplesToAnalyze- the samples that will actually be modelled, or null to use all of them
-
createProtocolForConfig
public static Protocol createProtocolForConfig(DifferentialExpressionAnalysisConfig config, Map<ExperimentalFactor, FactorValue> baselineFactorValues) -
formatInteraction
Format an interaction of factors. -
buildDesignMatrix
public static ObjectMatrix<BioMaterial, ExperimentalFactor, Object> buildDesignMatrix(List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, boolean allowMissingValues) Build a design matrix for the given factors and samples.- Parameters:
factors- factorssamplesUsed- the samples usedallowMissingValues- whether to allow missing values, if set to true, the returned matrix may contain nulls- Returns:
- the experimental design matrix
- Throws:
IllegalStateException- if missing values are found and allowMissingValues is false
-
buildRDesignMatrix
public static ObjectMatrix<String,String, buildRDesignMatrixObject> (List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, boolean allowMissingValues) Build an R-friendly design matrix.Rows and columns use names derived from
nameForR(BioMaterial),nameForR(ExperimentalFactor)andnameForR(FactorValue, boolean)such that the resulting matrix can be passed to R for analysis. It is otherwise identical tobuildDesignMatrix(List, List, boolean). -
buildRDesignMatrix
public static ObjectMatrix<String,String, buildRDesignMatrixObject> (List<ExperimentalFactor> factors, List<BioMaterial> samplesUsed, Map<ExperimentalFactor, FactorValue> baselines, boolean allowMissingValues) A variant ofbuildRDesignMatrix(List, List, boolean)that allows for reusing baselines for repeated calls. This is used for subset analysis. -
nameForR
Create a name for a sample suitable for R. -
nameForR
Create a name for the factor that is suitable for R. -
nameForR
Create a name for the factor value that is suitable for R.
-