DifferentialExperiment extends Experiment<Contrast> { @Override public JsonArray groupingsForHeatmap() { ExperimentDesign experimentDesign = getExperimentDesign(); ExperimentDisplayDefaults experimentDisplayDefaults = getDisplayDefaults(); DataColumnGroup.DataColumnGroupList<Contrast> dataColumnGroupList = new DataColumnGroup.DataColumnGroupList<>(experimentDisplayDefaults); dataColumnGroupList.addDataColumnGroupIfNotPresent("Comparison Name", true); for (String factorHeader: experimentDesign.getFactorHeaders()) { dataColumnGroupList.addDataColumnGroupIfNotPresent(factorHeader, false); } for (String sampleHeader: experimentDesign.getSampleHeaders()) { dataColumnGroupList.addDataColumnGroupIfNotPresent(sampleHeader, false); } for (Contrast dataColumnDescriptor: getDataColumnDescriptors()) { dataColumnGroupList.addValueToGroupingInGroup( "Comparison Name", dataColumnDescriptor.getDisplayName(), dataColumnDescriptor); for (String assayAnalyzedForThisDataColumn : dataColumnDescriptor.assaysAnalyzedForThisDataColumn()) { for (Factor factor : experimentDesign.getFactors(assayAnalyzedForThisDataColumn)) { dataColumnGroupList.addValueToGroupingInGroup( factor.getHeader(), factor.getValue(), dataColumnDescriptor); } for (SampleCharacteristic sampleCharacteristic : experimentDesign.getSampleCharacteristics(assayAnalyzedForThisDataColumn)) { dataColumnGroupList.addValueToGroupingInGroup( sampleCharacteristic.header(), sampleCharacteristic.value(), dataColumnDescriptor); } } } return dataColumnGroupList.asJson(); } DifferentialExperiment(String accession, Date lastUpdate, List<Pair<Contrast, Boolean>> contrasts,
                                  String description, Species species, Collection<String> pubMedIds,
                                  Collection<String> dois, ExperimentDesign experimentDesign); protected  DifferentialExperiment(ExperimentType experimentType, String accession, Date lastUpdate,
                                     List<Pair<Contrast, Boolean>> contrasts, String description, Species species,
                                     Collection<String> pubMedIds, Collection<String> dois,
                                     ExperimentDesign experimentDesign); boolean doesContrastHaveCttvPrimaryAnnotation(Contrast contrast); @Override ExperimentInfo buildExperimentInfo(); @Override JsonArray groupingsForHeatmap();  }
@Test public void groupingsForHeatmapIncludeComparisonName() { DifferentialExperiment experiment = createDifferentialExperiment( "accession", ImmutableList.of(c1), ExperimentDesignTest.mockExperimentDesign(ImmutableList.of(referenceAssay1, testAssay1))); JsonArray result = experiment.groupingsForHeatmap(); assertThat(result.size(), greaterThan(0)); assertThat(result.get(0).getAsJsonObject().get("name").getAsString(), equalToIgnoringCase("comparison_name")); }
@Test public void sampleCharacteristicsThatArePerWholeContrastShowUpAsTestThenReference() { ExperimentDesign experimentDesign = new ExperimentDesign(); experimentDesign.putFactor(referenceAssay1.getFirstAssayAccession(), "infect", "totally_normal"); experimentDesign.putFactor(testAssay1.getFirstAssayAccession(), "infect", "very_disease"); DifferentialExperiment experiment = createDifferentialExperiment("accession", ImmutableList.of(c1), experimentDesign); JsonArray result = experiment.groupingsForHeatmap(); assertThat(result.size(), is(2)); String stringDump = GSON.toJson(result); assertThat(stringDump.indexOf("very_disease"), lessThan(stringDump.indexOf("totally_normal"))); }