Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
austenem committed Oct 29, 2024
2 parents d2b2a00 + 6b5314a commit ad9021e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-update-epic-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Use assay_display_name instead of pipeline when labelling EPIC dataset sections.
- Update language in processed dataset sections from "pipeline" to "analysis".
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ function HelperPanelBody() {
{currentDataset.description}
</HelperPanelBodyItem>
)}
<HelperPanelBodyItem label="Pipeline">{currentDataset.pipeline}</HelperPanelBodyItem>
<HelperPanelBodyItem label="Analysis Type">
{currentDataset.pipeline ?? currentDataset.assay_display_name[0]}
</HelperPanelBodyItem>
<HelperPanelBodyItem label="Group">{currentDataset.group_name}</HelperPanelBodyItem>
<HelperPanelBodyItem label={dateLabel}>{date && formatDate(date, 'yyyy-MM-dd')}</HelperPanelBodyItem>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { sectionIconMap } from 'js/shared-styles/icons/sectionIconMap';
import ProcessedDataset from './ProcessedDataset';
import { SectionDescription } from './ProcessedDataset/SectionDescription';
import HelperPanel from './HelperPanel';
import { usePipelineCountsInfo, useSortedSearchHits } from './hooks';
import { useAnalysesCountInfo, useSortedSearchHits } from './hooks';
import CollapsibleDetailPageSection from '../DetailPageSection/CollapsibleDetailPageSection';

function ProcessedDataSection() {
const processedDatasets = useProcessedDatasets();
const sortedSearchHits = useSortedSearchHits(processedDatasets.searchHits);

const { pipelinesText, pipelineCountsText } = usePipelineCountsInfo(
const { analysesText, analysesCountText } = useAnalysesCountInfo(
processedDatasets.searchHits.map((dataset) => dataset._source),
);

Expand All @@ -25,7 +25,7 @@ function ProcessedDataSection() {
icon={sectionIconMap['processed-data']}
>
<SectionDescription
addendum={<LabelledSectionText label={pipelinesText}>{pipelineCountsText}</LabelledSectionText>}
addendum={<LabelledSectionText label={analysesText}>{analysesCountText}</LabelledSectionText>}
>
This section lists analyses generated based on this dataset. These analyses are represented as processed
datasets and are either generated by HuBMAP using uniform processing pipelines or by an external processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function ProcessedDatasetAccordion({ children }: PropsWithChildren) {
<AccordionSummary expandIcon={<ArrowDropDownRounded />}>
{isLoading ? iconPlaceholder : visualizationIcon}
<Typography variant="subtitle1" color="inherit" component="h4">
{sectionDataset.pipeline}
{sectionDataset.pipeline ?? sectionDataset.assay_display_name[0]}
</Typography>
<Typography variant="body1" ml="auto" component="div" display="flex" alignItems="center" gap={1}>
<StatusIcon status={sectionDataset.status} noColor={isExpanded} tooltip />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CreationAction } from 'js/components/types';
import { renderHook } from 'test-utils/functions';
import { useSortedSearchHits, createdByCentralProcess, datasetIsPublished, usePipelineCountsInfo } from './hooks';
import { useSortedSearchHits, createdByCentralProcess, datasetIsPublished, useAnalysesCountInfo } from './hooks';

const testDatasets: {
_id: string;
Expand Down Expand Up @@ -94,8 +94,8 @@ it('checks if dataset is published', () => {
expect(datasetIsPublished(testDatasets[2]._source)).toBe(true);
});

it('counts pipelines and their occurrences', () => {
const { pipelinesText, pipelineCountsText } = usePipelineCountsInfo(testDatasets.map((dataset) => dataset._source));
expect(pipelinesText).toBe('Pipelines (2)');
expect(pipelineCountsText).toBe('Cytokit + SPRM (2) and Segmentation Mask');
it('counts analyses and their occurrences', () => {
const { analysesText, analysesCountText } = useAnalysesCountInfo(testDatasets.map((dataset) => dataset._source));
expect(analysesText).toBe('Analyses (2)');
expect(analysesCountText).toBe('Cytokit + SPRM (2) and Segmentation Mask');
});
28 changes: 13 additions & 15 deletions context/app/static/js/components/detailPage/ProcessedData/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,26 @@ export function useSortedSearchHits(datasets: ReturnType<typeof useProcessedData
}

/**
* Formats the processed datasets' pipelines and their counts for presentation.
* @param datasets The processed datasets to count the pipelines of.
* @returns Text for the pipelines label, and additional text for each pipeline and its count.
* Formats the processed datasets' analyses and their counts for presentation.
* @param datasets The processed datasets to count the analyses of.
* @returns Text for the analyses label, and additional text for each analysis and its count.
*/
export function usePipelineCountsInfo(datasets: Pick<ProcessedDatasetInfo, 'pipeline'>[]) {
const pipelines = datasets.map((dataset) => dataset.pipeline);
const pipelineCounts = pipelines.reduce(
(acc, pipeline) => {
if (pipeline) {
acc[pipeline] = (acc[pipeline] || 0) + 1;
}
export function useAnalysesCountInfo(datasets: Pick<ProcessedDatasetInfo, 'pipeline' | 'assay_display_name'>[]) {
const analyses = datasets.map((dataset) => dataset.pipeline ?? dataset.assay_display_name[0]);
const analysesCount = analyses.reduce(
(acc, analysis) => {
acc[analysis] = (acc[analysis] || 0) + 1;
return acc;
},
{} as Record<string, number>,
);
const pipelinesText = `Pipelines (${Object.keys(pipelineCounts).length})`;
const pipelineCountsText = generateCommaList(
Object.entries(pipelineCounts).map(([pipeline, count]) => (count > 1 ? `${pipeline} (${count})` : pipeline)),
const analysesText = `Analyses (${Object.keys(analysesCount).length})`;
const analysesCountText = generateCommaList(
Object.entries(analysesCount).map(([analysis, count]) => (count > 1 ? `${analysis} (${count})` : analysis)),
);

return {
pipelinesText,
pipelineCountsText,
analysesText,
analysesCountText,
};
}
6 changes: 4 additions & 2 deletions context/app/static/js/pages/Dataset/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function getProcessedDatasetSection({
hit: Required<SearchHit<ProcessedDatasetInfo>>;
conf?: VitessceConf;
}) {
const { pipeline, hubmap_id, files, metadata, visualization, creation_action, contributors } = hit._source;
const { pipeline, assay_display_name, hubmap_id, files, metadata, visualization, creation_action, contributors } =
hit._source;

const shouldDisplaySection = {
summary: true,
Expand All @@ -146,10 +147,11 @@ function getProcessedDatasetSection({
};

const sectionsToDisplay = Object.entries(shouldDisplaySection).filter(([_k, v]) => v === true);
const sectionTitle = pipeline ?? assay_display_name[0] ?? hubmap_id;

return {
// TODO: Improve the lookup for descendants to exclude anything with a missing pipeline name
...getSectionFromString(pipeline ?? hubmap_id, datasetSectionId(hit._source, 'section')),
...getSectionFromString(sectionTitle, datasetSectionId(hit._source, 'section')),
items: sectionsToDisplay.map(([s]) => ({
...getSectionFromString(s, datasetSectionId(hit._source, s)),
hash: datasetSectionId(hit._source, s),
Expand Down

0 comments on commit ad9021e

Please sign in to comment.