Skip to content

Commit

Permalink
multiple updates, esp. to cohorts & subsets pages
Browse files Browse the repository at this point in the history
... also fix for variant identifier referencing
  • Loading branch information
mbaudis committed Aug 2, 2024
1 parent 000b5ba commit d91d8c2
Show file tree
Hide file tree
Showing 33 changed files with 281 additions and 322 deletions.
21 changes: 1 addition & 20 deletions src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,33 +127,14 @@ function Side({ onClick }) {
/>
<MenuInternalLinkItem
href="/progenetix-cohorts/TCGA"
label="TCGA Samples"
label="TCGA Cancer Samples"
isSub="isSub"
/>
<MenuInternalLinkItem
href="/progenetix-cohorts/oneKgenomes"
label="1000 Genomes Reference Samples"
isSub="isSub"
/>
{/*
<MenuInternalLinkItem
href="/progenetix-cohorts/DIPG"
label="DIPG Samples"
isSub="isSub"
/>
*/}
<MenuInternalLinkItem
href="/subsets/cbioportal-subsets"
label="cBioPortal Studies"
isSub="isSub"
/>
{/*
<MenuInternalLinkItem
href="/progenetix-cohorts/gao-2021-signatures"
label="Gao & Baudis, 2021"
isSub="isSub"
/>
*/}
<MenuInternalLinkItem
href="http://cancercelllines.org"
label={
Expand Down
111 changes: 111 additions & 0 deletions src/components/SubsetLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {
SITE_DEFAULTS,
useServiceItemDelivery,
sampleSearchPageFiltersLink,
NoResultsHelp
} from "../hooks/api"
import { Loader } from "./Loader"
import { SubsetHistogram } from "./SVGloaders"
// import { ShowJSON } from "./RawData"
import { ExternalLink, InternalLink } from "./helpersShared/linkHelpers"

const service = "collations"

export function SubsetLoader({ id, datasetIds }) {
const { data, error, isLoading } = useServiceItemDelivery(
id,
service,
datasetIds
)
return (
<Loader isLoading={isLoading} hasError={error} background>
{data && (
<SubsetResponse response={data} id={id} datasetIds={datasetIds} />
)}
</Loader>
)
}

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 && (
<>
<h5>Subset Type</h5>
<ul>
<li>
{subset.type}{" "}
<ExternalLink
href={subset.reference}
label={subset.id}
/>
</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>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { keyBy, merge } from "lodash"
import { SubsetHistogram } from "./SVGloaders"
import { buildTree, buildTreeForDetails, TreePanel } from "./classificationTree/TreePanel"

export default function SubsetsLoader({ collationTypes, datasetIds, defaultTreeDepth }) {
export default function SubsetsHierarchyLoader({ collationTypes, datasetIds, defaultTreeDepth }) {
const bioSubsetsHierarchiesReply = useCollationsByType({
datasetIds,
method: "paths",
collationTypes
})

const allBioSubsetsReply = useCollationsById({
datasetIds
})
const allBioSubsetsReply = useCollationsById({datasetIds})

return (
<WithData
Expand Down
40 changes: 22 additions & 18 deletions src/components/classificationTree/SubsetsTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FaAngleDown, FaAngleRight } from "react-icons/fa"
import Tippy from "@tippyjs/react"
import { FixedSizeTree as VTree } from "react-vtree"
import useDebounce from "../../hooks/debounce"
import { min } from "lodash"
// import { min } from "lodash"
import { filterNode } from "./tree"

const ROW_HEIGHT = 30
Expand Down Expand Up @@ -86,7 +86,7 @@ export function SubsetsTree({
)}
{checkedSubsets.map((subset) => (
<li className="tag is-primary" key={subset.id}>
{subset.label} ({subset.count})
{subset.label ? subset.label : subset.id} ({subset.count})
</li>
))}
</ul>
Expand Down Expand Up @@ -179,7 +179,7 @@ function Node({
style,
setOpen
}) {
const isSearchPossible = subset && canSearch(subset)
const isSearchPossible = true // subset && canSearch(subset)
const even = index % 2 === 0
const detailsPage = "subset"
return (
Expand Down Expand Up @@ -221,17 +221,21 @@ function Node({
</span>
)}
<Tippy content={`Show data for subset "${subset.label}"`}>
<a
href={`/${detailsPage}/?id=${subsetId}&datasetIds=${datasetIds}`}
>
<>
{(subset?.label && (
<span className="Subsets__tree__label" title={subset.label}>
{subset.label}
<a href={`/${detailsPage}/?id=${subsetId}&datasetIds=${datasetIds}`}>
{subset.label}</a>: {subsetId}
</span>
)) || <span>&nbsp;</span>}
</a>
))
||
<span className="Subsets__tree__label" title={subsetId}>
<a href={`/${detailsPage}/?id=${subsetId}&datasetIds=${datasetIds}`}>
{subsetId}</a>: {subsetId}
</span>
}
</>
</Tippy>
<span>: {subsetId}</span>
{isSearchPossible ? (
<Tippy content={`Click to retrieve samples for ${subsetId}`}>
<a
Expand Down Expand Up @@ -352,11 +356,11 @@ function sampleSelectUrl({ subsets, datasetIds, sampleFilterScope }) {
return sampleSearchPageFiltersLink({ datasetIds, sampleFilterScope, filters })
}

function canSearch(subset) {
// Only necessary for NCIT
if (!subset.id.includes("NCIT:")) return true
const minDepth = subset.hierarchyPaths
? min(subset.hierarchyPaths?.map((hp) => hp.depth))
: 999
return minDepth >= 2
}
// function canSearch(subset) {
// // Only necessary for NCIT
// if (!subset.id.includes("NCIT:")) return true
// const minDepth = subset.hierarchyPaths
// ? min(subset.hierarchyPaths?.map((hp) => hp.depth))
// : 999
// return minDepth >= 2
// }
4 changes: 2 additions & 2 deletions src/components/searchResults/VariantsDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default function VariantsDataTable({ apiReply, datasetId }) {
Cell: ({ value: caseLevelData }) =>
caseLevelData.map((cld, i) => (
<div key={i}>
<a href={`/variant?id=${cld.id}&datasetIds=${datasetId}`} target="_blank" rel="noreferrer">
V: {cld.id}
<a href={`/variant?id=${cld.variantId}&datasetIds=${datasetId}`} target="_blank" rel="noreferrer">
V: {cld.variantId}
</a>
<br/>
<a href={`/biosample?id=${cld.biosampleId}&datasetIds=${datasetId}`} target="_blank" rel="noreferrer">
Expand Down
18 changes: 12 additions & 6 deletions src/hooks/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export const SITE_DEFAULTS = {
export const THISYEAR = new Date().getFullYear()
export const BIOKEYS = ["icdoMorphology", "icdoTopography", "histologicalDiagnosis"]

// "sampleOriginDetail"

export function useProgenetixApi(...args) {
const { data, error, ...other } = useExtendedSWR(...args)
if (data) {
Expand Down Expand Up @@ -77,7 +75,6 @@ export async function tryFetch(url, fallBack = "N/A") {
}
}
}

/**
* When param is null no query will be triggered.
*/
Expand All @@ -92,6 +89,15 @@ export function useBeaconQuery(queryData) {
)
}

export function urlRetrieveIds(urlQuery) {
var { id, datasetIds } = urlQuery
if (!datasetIds) {
datasetIds = SITE_DEFAULTS.DATASETID
}
const hasAllParams = id && datasetIds
return {id, datasetIds, hasAllParams}
}

export function useAggregatorQuery(queryData) {
return useProgenetixApi(
queryData
Expand Down Expand Up @@ -306,11 +312,11 @@ export function getServiceItemUrl(id, collection, datasetIds) {
return `${SITE_DEFAULTS.API_PATH}services/${collection}?id=${id}&datasetIds=${datasetIds}`
}

export function NoResultsHelp(id, entity) {
export function NoResultsHelp(entity) {
return (
<div className="notification is-size-5">
This page will only show content if called with an existing {entity} ID;{" "}
is not valid.
This page will only show content if called with an existing {entity}{" "}
&quot;id&quot; value.
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/data-pages/NCIT_SubsetsPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"
import { Layout } from "../../components/Layout"
import SubsetsLoader from "../../components/SubsetsLoader"
import SubsetsHierarchyLoader from "../../components/SubsetsHierarchyLoader"

export default function NCIT_SubsetsPage() {
return (
Expand All @@ -19,7 +19,7 @@ export default function NCIT_SubsetsPage() {
response.
</p>
</div>
<SubsetsLoader collationTypes="NCIT" datasetIds="progenetix" />
<SubsetsHierarchyLoader collationTypes="NCIT" datasetIds="progenetix" />
</Layout>
)
}
17 changes: 0 additions & 17 deletions src/modules/data-pages/NCITclinical_SubsetsPage.js

This file was deleted.

50 changes: 50 additions & 0 deletions src/modules/data-pages/TCGAcancers_dataPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from "react"
import { Layout } from "../../components/Layout"
import { SubsetLoader } from "../../components/SubsetLoader"
import Panel from "../../components/Panel"
import SubsetsHierarchyLoader from "../../components/SubsetsHierarchyLoader"

const datasetIds = "progenetix"
const subsetId = "pgx:cohort-TCGAcancers"

export default function arraymap_dataPage() {
return (
<Layout title="TCGA Cancer Subsets" headline="">
<Panel>
<SubsetLoader
id={subsetId}
datasetIds={datasetIds}
/>
</Panel>
<Panel>
<ThisSubset />
</Panel>
<Panel heading="TCGA Cancer Studies">
<SubsetsHierarchyLoader collationTypes="TCGAproject" datasetIds="progenetix" />
</Panel>
</Layout>
)
}

function ThisSubset() {
return (
<>
<div style={{ display: "flex" }}>
This page represents the TCGA subset of the Progenetix
collection, based on 22142 samples (tumor and reeferences) from The
Cancer Genome Atlas project. The results are based upon data generated
by the TCGA Research Network. Disease-specific subsets of TCGA data (aka. projects) can be
accessed below.
<img
src={"/img/tcga.png"}
style={{
float: "right",
width: "200px",
border: "0px",
margin: "-20px -20px 0px 0px"
}}
/>
</div>
</>
)
}
Loading

0 comments on commit d91d8c2

Please sign in to comment.