Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public DifferentialExpressionAnalysisResultSetValueObject( ExpressionAnalysisRes
if ( analysisResultSet.getBaselineGroup() != null ) {
this.baselineGroup = new FactorValueBasicValueObject( analysisResultSet.getBaselineGroup() );
}
if ( analysisResultSet.getSecondBaselineGroup() != null ) {
this.secondBaselineGroup = new FactorValueBasicValueObject( analysisResultSet.getSecondBaselineGroup() );
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import ubic.gemma.model.expression.experiment.FactorValue;
import ubic.gemma.model.genome.Gene;

import javax.annotation.Nullable;
import javax.persistence.Transient;
import java.util.HashSet;
import java.util.Set;
Expand All @@ -40,7 +41,10 @@ public class ExpressionAnalysisResultSet extends FactorAssociatedAnalysisResultS
private static final long serialVersionUID = 7226901182513177574L;
private Integer numberOfProbesTested;
private Integer numberOfGenesTested;
@Nullable
private FactorValue baselineGroup;
@Nullable
private FactorValue secondBaselineGroup;
private Set<DifferentialExpressionAnalysisResult> results = new HashSet<>();
private DifferentialExpressionAnalysis analysis;
private PvalueDistribution pvalueDistribution;
Expand Down Expand Up @@ -91,18 +95,38 @@ public void setAnalysis( DifferentialExpressionAnalysis analysis ) {
}

/**
* @return The group considered baseline when computing scores and 'upRegulated'. This might be a control group if it could
* be recognized. For continuous factors, this would be null. For interaction terms we do not compute this so it
* will also be null.
* The group considered baseline when computing scores and 'upRegulated'. This might be a control group if it could
* be recognized.
* <p>
* Corresponds to {@link ContrastResult#getFactorValue()}.
* <p>
* For interactions, {@link #getSecondBaselineGroup()} will also be populated.
* <p>
* For continuous factors, this would be {@code null}.
*/
@Nullable
public FactorValue getBaselineGroup() {
return this.baselineGroup;
}

public void setBaselineGroup( FactorValue baselineGroup ) {
public void setBaselineGroup( @Nullable FactorValue baselineGroup ) {
this.baselineGroup = baselineGroup;
}

/**
* If this result set is for an interaction of factors, this is the second baseline group.
* <p>
* Corresponds to {@link ContrastResult#getSecondFactorValue()}.
*/
@Nullable
public FactorValue getSecondBaselineGroup() {
return this.secondBaselineGroup;
}

public void setSecondBaselineGroup( @Nullable FactorValue secondBaselineGroup ) {
this.secondBaselineGroup = secondBaselineGroup;
}

public Set<HitListSize> getHitListSizes() {
return this.hitListSizes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ public void thaw( ExpressionAnalysisResultSet ears ) {
Hibernate.initialize( ears.getAnalysis().getSubsetFactorValue() );
Hibernate.initialize( ears.getAnalysis().getSubsetFactorValue().getExperimentalFactor() );
}

if ( ears.getBaselineGroup() != null ) {
Hibernate.initialize( ears.getBaselineGroup() );
Hibernate.initialize( ears.getBaselineGroup().getExperimentalFactor() );
}
if ( ears.getSecondBaselineGroup() != null ) {
Hibernate.initialize( ears.getSecondBaselineGroup() );
Hibernate.initialize( ears.getSecondBaselineGroup().getExperimentalFactor() );
}
}

@Override
Expand Down Expand Up @@ -373,7 +382,7 @@ public Map<Long, List<Gene>> loadResultToGenesMap( ExpressionAnalysisResultSet r
*/
private void populateBaselines( List<DifferentialExpressionAnalysisResultSetValueObject> vos ) {
Collection<DifferentialExpressionAnalysisResultSetValueObject> vosWithMissingBaselines = vos.stream()
.filter( vo -> vo.getBaselineGroup() == null )
.filter( vo -> vo.getBaselineGroup() == null && vo.getSecondBaselineGroup() == null )
.collect( Collectors.toList() );
if ( vosWithMissingBaselines.isEmpty() ) {
return;
Expand Down
27 changes: 27 additions & 0 deletions gemma-core/src/main/resources/sql/migrations/db.1.32.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
alter table ANALYSIS_RESULT_SET
add column SECOND_BASELINE_GROUP_FK BIGINT references FACTOR_VALUE (ID) after BASELINE_GROUP_FK;

-- populate baselines for interaction terms
update ANALYSIS_RESULT_SET
join DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT
on ANALYSIS_RESULT_SET.ID = DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT.RESULT_SET_FK
join CONTRAST_RESULT
on DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT.ID = CONTRAST_RESULT.DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT_FK

-- first baseline
join FACTOR_VALUE fv1 on CONTRAST_RESULT.FACTOR_VALUE_FK = fv1.ID
join ANALYSIS_RESULT_SET b1rs on b1rs.ANALYSIS_FK = ANALYSIS_RESULT_SET.ANALYSIS_FK
join FACTOR_VALUE b1g
on b1g.ID = b1rs.BASELINE_GROUP_FK and b1g.EXPERIMENTAL_FACTOR_FK = fv1.EXPERIMENTAL_FACTOR_FK

-- second baseline
join FACTOR_VALUE fv2 on CONTRAST_RESULT.SECOND_FACTOR_VALUE_FK = fv2.ID
join ANALYSIS_RESULT_SET b2rs on b2rs.ANALYSIS_FK = ANALYSIS_RESULT_SET.ANALYSIS_FK
join FACTOR_VALUE b2g
on b2g.ID = b2rs.BASELINE_GROUP_FK and b2g.EXPERIMENTAL_FACTOR_FK = fv2.EXPERIMENTAL_FACTOR_FK

set ANALYSIS_RESULT_SET.BASELINE_GROUP_FK = b1g.ID,
ANALYSIS_RESULT_SET.SECOND_BASELINE_GROUP_FK = b2g.ID

where ANALYSIS_RESULT_SET.BASELINE_GROUP_FK is null
and ANALYSIS_RESULT_SET.SECOND_BASELINE_GROUP_FK is null;
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
lazy="proxy" fetch="select">
<column name="BASELINE_GROUP_FK" not-null="false" sql-type="BIGINT"/>
</many-to-one>
<many-to-one name="secondBaselineGroup" class="ubic.gemma.model.expression.experiment.FactorValue"
lazy="proxy" fetch="select">
<column name="SECOND_BASELINE_GROUP_FK" not-null="false" sql-type="BIGINT"/>
</many-to-one>
<!-- FIXME: use cascade="all" when https://github.com/PavlidisLab/Gemma/issues/825 is resolved -->
<set name="results" lazy="true" fetch="select" inverse="true" mutable="false">
<key foreign-key="DIFFERENTIAL_EXPRESSION_ANALYSIS_RESULT_RESULT_SET_FKC">
Expand Down