Package ubic.basecode.math.linearmodels
Class DesignMatrix
java.lang.Object
ubic.basecode.math.linearmodels.DesignMatrix
Represents the A matrix in regression problems posed as Ax=b. The starting point is a matrix of sample information,
where the rows are sample names and the columns are the names of factors or covariates. Intercept and interaction
terms can be added.
Baseline levels are initially determined by the order in which factor levels appear. You can re-level using the setBaseline method.
- Author:
- paul
-
Constructor Summary
ConstructorsConstructorDescriptionDesignMatrix
(Object[] factor, int start, String factorName) DesignMatrix
(ObjectMatrix<String, String, ?> sampleInfo, boolean intercept) DesignMatrix
(ObjectMatrix<String, String, ? extends Object> sampleInfo) DesignMatrix
(ObjectMatrix<String, String, Object> design, boolean intercept, boolean strict) DesignMatrix
(StringMatrix<String, String> sampleInfo) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ObjectMatrix<String, String, Object> sampleInfo) Append additional factors/covariates to thisvoid
Add interaction term; only works if there exactly two factors so this can figure out which interaction to add.void
addInteraction
(String... interactionTerms) This will not add the interaction unless all of the terms are already part of the design, and interactions that obviously can't be estimated will be dropped if possible, but otherwise this is fairly brain dead.getBaseline
(String factorName) Collection
<String[]> getTerms()
boolean
boolean
In limma, the contrasts are built by referring to the coefficients by name, which isn't what we want.protected void
rebuild()
Refresh the design matrix, for example after releveling.void
setBaseline
(String factorName, String baselineFactorValue) toString()
-
Constructor Details
-
DesignMatrix
- Parameters:
factor
- in form of Doubles or Strings. Any other types will yield errors.start
-
-
DesignMatrix
- Parameters:
sampleInfo
- in form of Doubles or Strings. Any other types will yield errors.
-
DesignMatrix
- Parameters:
sampleInfo
- in form of Doubles or Strings. Any other types will yield errors.intercept
-
-
DesignMatrix
-
DesignMatrix
- Parameters:
design
-intercept
- whether to include an intercept in the modelstrict
- whether to remove columns from the design matrix that are unlikely to be useable. By default this is "true" for other constructors.
-
-
Method Details
-
getInteractionTerms
- Returns:
- a collection of String arrays. If empty, there are no interactions. Each array represents an interaction in the model. The elements of the array are the terms included in the interaction, as Strings provided when calling addInteraction.
-
makeContrasts
In limma, the contrasts are built by referring to the coefficients by name, which isn't what we want.- Returns:
-
add
Append additional factors/covariates to this- Parameters:
sampleInfo
-
-
addInteraction
public void addInteraction()Add interaction term; only works if there exactly two factors so this can figure out which interaction to add. For more control use the other method. -
addInteraction
This will not add the interaction unless all of the terms are already part of the design, and interactions that obviously can't be estimated will be dropped if possible, but otherwise this is fairly brain dead.- Parameters:
interactionTerms
-
-
getAssign
- Returns:
-
getBaseline
-
getDoubleMatrix
-
getLevelsForFactors
-
getMatrix
-
getTerms
-
getValuesForFactors
-
hasIntercept
public boolean hasIntercept() -
isHasIntercept
public boolean isHasIntercept() -
setBaseline
- Parameters:
factorName
-baselineFactorValue
-
-
toString
-
rebuild
protected void rebuild()Refresh the design matrix, for example after releveling.
-