forked from progenetix/progenetix-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,528 additions
and
264 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useFilterTreesByType } from "../hooks/api" | ||
import { WithData } from "./Loader" | ||
import React from "react" | ||
import { keyBy } from "lodash" | ||
import { buildTree, TreePanel } from "./classificationTree/TreePanel" | ||
|
||
export default function SubsetsHierarchyLoader({ collationTypes, datasetIds, defaultTreeDepth }) { | ||
const collationsHierarchyReply = useFilterTreesByType({ | ||
datasetIds, | ||
collationTypes | ||
}) | ||
|
||
return ( | ||
<WithData | ||
apiReply={collationsHierarchyReply} | ||
background | ||
render={(collationsHierarchyReply) => ( | ||
<SubsetsResponse | ||
collationsHierarchies={collationsHierarchyReply.response.filteringTerms} | ||
datasetIds={datasetIds} | ||
defaultTreeDepth={defaultTreeDepth} | ||
/> | ||
)} | ||
/> | ||
) | ||
} | ||
|
||
function SubsetsResponse({ collationsHierarchies, datasetIds, defaultTreeDepth }) { | ||
const subsetById = keyBy(collationsHierarchies, "id") | ||
const { tree, size } = buildTree(collationsHierarchies, subsetById) | ||
|
||
return ( | ||
<TreePanel | ||
datasetIds={datasetIds} | ||
subsetById={subsetById} | ||
tree={tree} | ||
size={size} | ||
defaultTreeDepth={defaultTreeDepth} | ||
sampleFilterScope="allTermsFilters" | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,111 @@ | ||
import { useCollationsByType, useCollationsById } from "../hooks/api" | ||
import { WithData } from "./Loader" | ||
import React from "react" | ||
import { keyBy, merge } from "lodash" | ||
import { | ||
SITE_DEFAULTS, | ||
useServiceItemDelivery, | ||
sampleSearchPageFiltersLink, | ||
NoResultsHelp | ||
} from "../hooks/api" | ||
import { Loader } from "./Loader" | ||
import { SubsetHistogram } from "./SVGloaders" | ||
import { buildTree, buildTreeForDetails, TreePanel } from "./classificationTree/TreePanel" | ||
// import { ShowJSON } from "./RawData" | ||
import { ExternalLink, InternalLink } from "./helpersShared/linkHelpers" | ||
|
||
export default function SubsetsLoader({ collationTypes, datasetIds, defaultTreeDepth }) { | ||
const bioSubsetsHierarchiesReply = useCollationsByType({ | ||
datasetIds, | ||
method: "paths", | ||
collationTypes | ||
}) | ||
const service = "collations" | ||
|
||
const allBioSubsetsReply = useCollationsById({ | ||
export function SubsetLoader({ id, datasetIds }) { | ||
const { data, error, isLoading } = useServiceItemDelivery( | ||
id, | ||
service, | ||
datasetIds | ||
}) | ||
|
||
) | ||
return ( | ||
<WithData | ||
apiReply={bioSubsetsHierarchiesReply} | ||
background | ||
render={(bioSubsetsHierarchiesResponse) => ( | ||
<WithData | ||
apiReply={allBioSubsetsReply} | ||
background | ||
render={(allBioSubsetsResponse) => ( | ||
<SubsetsResponse | ||
bioSubsetsHierarchies={bioSubsetsHierarchiesResponse.response.results} | ||
allBioSubsets={allBioSubsetsResponse.response.results} | ||
datasetIds={datasetIds} | ||
defaultTreeDepth={defaultTreeDepth} | ||
/> | ||
)} | ||
/> | ||
<Loader isLoading={isLoading} hasError={error} background> | ||
{data && ( | ||
<SubsetResponse response={data} id={id} datasetIds={datasetIds} /> | ||
)} | ||
/> | ||
</Loader> | ||
) | ||
} | ||
|
||
function SubsetsResponse({ bioSubsetsHierarchies, allBioSubsets, datasetIds, defaultTreeDepth }) { | ||
const isDetailPage = bioSubsetsHierarchies.length === 1 | ||
// We merge both subsets from hierarchies and subsets from allSubsets. | ||
// This is because some children in the bioSubsetsHierarchies don't have labels or sample count information. | ||
const subsetById = merge(keyBy(bioSubsetsHierarchies, "id"), allBioSubsets) | ||
const { tree, size } = isDetailPage | ||
? buildTreeForDetails(bioSubsetsHierarchies, subsetById) | ||
: buildTree(bioSubsetsHierarchies, subsetById) | ||
function SubsetResponse({ response, datasetIds }) { | ||
if (!response.response.results[0]) { | ||
return NoResultsHelp("subsetdetails") | ||
} | ||
return <Subset subset={response.response.results[0]} datasetIds={datasetIds} /> | ||
} | ||
|
||
function Subset({ subset, datasetIds }) { | ||
|
||
const filters = subset.id | ||
const sampleFilterScope = "allTermsFilters" | ||
|
||
return ( | ||
<section className="content"> | ||
<h2> | ||
{subset.label} ({subset.id}) | ||
</h2> | ||
|
||
{subset.type && ( | ||
<> | ||
{isDetailPage && ( | ||
<div className="mb-3"> | ||
<SubsetHistogram | ||
id={bioSubsetsHierarchies[0].id} | ||
datasetIds={datasetIds} | ||
loaderProps={{ | ||
background: true, | ||
colored: true | ||
}} | ||
<h5>Subset Type</h5> | ||
<ul> | ||
<li> | ||
{subset.type}{" "} | ||
<ExternalLink | ||
href={subset.reference} | ||
label={subset.id} | ||
/> | ||
</div> | ||
)} | ||
<TreePanel | ||
datasetIds={datasetIds} | ||
subsetById={subsetById} | ||
tree={tree} | ||
size={size} | ||
defaultTreeDepth={defaultTreeDepth} | ||
sampleFilterScope="allTermsFilters" | ||
/> | ||
</li> | ||
</ul> | ||
</> | ||
)} | ||
|
||
<h5>Sample Counts</h5> | ||
<ul> | ||
<li>{subset.count} samples</li> | ||
<li>{subset.codeMatches} direct <i>{subset.id}</i> code matches</li> | ||
{subset.cnvAnalyses && ( | ||
<li>{subset.cnvAnalyses} CNV analyses</li> | ||
)} | ||
{subset.frequencymapCnvAnalyses && ( | ||
<li> | ||
{subset.frequencymapCnvAnalyses} {" CNV analyses used in frequency calculations"} | ||
</li> | ||
)} | ||
</ul> | ||
<h5>CNV Histogram</h5> | ||
<div className="mb-3"> | ||
<SubsetHistogram | ||
id={subset.id} | ||
datasetIds={datasetIds} | ||
loaderProps={{background: true, colored: true}} | ||
/> | ||
</div> | ||
|
||
<h5> | ||
<InternalLink | ||
href={`${SITE_DEFAULTS.API_PATH}services/intervalFrequencies/${subset.id}/?output=pgxfreq`} | ||
label="Download CNV frequencies" | ||
/> | ||
</h5> | ||
<p> | ||
Download CNV frequency data for genomic 1Mb bins. | ||
</p> | ||
|
||
<h5> | ||
<InternalLink | ||
href={ sampleSearchPageFiltersLink({datasetIds, sampleFilterScope, filters}) } | ||
label={`Search for ${subset.id} Samples`} | ||
rel="noreferrer" | ||
target="_blank" | ||
/> | ||
</h5> | ||
<p> | ||
Select samples through the search form, e.g. by querying for specific | ||
genomic variants or phenotypes. | ||
</p> | ||
|
||
{/*<ShowJSON data={subset} />*/} | ||
|
||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.