@@ -13,39 +13,25 @@ import ScatterPlot from '~/components/visualization/ScatterPlot'
1313import StudyViolinPlot from '~/components/visualization/StudyViolinPlot'
1414import DotPlot from '~/components/visualization/DotPlot'
1515import Heatmap from '~/components/visualization/Heatmap'
16+ import Pathway from '~/components/visualization/Pathway'
1617import GeneListHeatmap from '~/components/visualization/GeneListHeatmap'
1718import GenomeView from './GenomeView'
18- import { getAnnotationValues , getShownAnnotation } from '~/lib/cluster-utils'
19+ import { getAnnotationValues , getEligibleLabels } from '~/lib/cluster-utils'
1920import RelatedGenesIdeogram from '~/components/visualization/RelatedGenesIdeogram'
2021import InferCNVIdeogram from '~/components/visualization/InferCNVIdeogram'
2122import useResizeEffect from '~/hooks/useResizeEffect'
2223import LoadingSpinner from '~/lib/LoadingSpinner'
2324import { log } from '~/lib/metrics-api'
2425import { getFeatureFlagsWithDefaults } from '~/providers/UserProvider'
25- import ExploreDisplayPanelManager from './ExploreDisplayPanelManager'
26+ import ExploreDisplayPanelManager , { getSelectedClusterAndAnnot } from './ExploreDisplayPanelManager'
2627import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'
2728import Tooltip from 'react-bootstrap/lib/Tooltip'
2829import PlotTabs from './PlotTabs'
2930import {
3031 initCellFaceting , filterCells , getFacetsParam , parseFacetsParam
3132} from '~/lib/cell-faceting'
33+ import { getIsPathway } from '~/lib/search-utils'
3234
33- /** Get the selected clustering and annotation, or their defaults */
34- export function getSelectedClusterAndAnnot ( exploreInfo , exploreParams ) {
35- if ( ! exploreInfo ) { return [ null , null ] }
36- const annotList = exploreInfo . annotationList
37- let selectedCluster
38- let selectedAnnot
39- if ( exploreParams ?. cluster ) {
40- selectedCluster = exploreParams . cluster
41- selectedAnnot = exploreParams . annotation
42- } else {
43- selectedCluster = annotList . default_cluster
44- selectedAnnot = annotList . default_annotation
45- }
46-
47- return [ selectedCluster , selectedAnnot ]
48- }
4935
5036/** Determine if current annotation has one-vs-rest or pairwise DE */
5137function getHasComparisonDe ( exploreInfo , exploreParams , comparison ) {
@@ -286,7 +272,7 @@ export default function ExploreDisplayTabs({
286272 const [ filterErrorText , setFilterErrorText ] = useState ( null )
287273
288274 const {
289- enabledTabs, disabledTabs, isGeneList, isGene, isMultiGene, hasIdeogramOutputs
275+ enabledTabs, disabledTabs, isGeneList, isGene, isPathway , isMultiGene, hasIdeogramOutputs
290276 } = getEnabledTabs ( exploreInfo , exploreParamsWithDefaults , cellFaceting )
291277
292278 // exploreParams object without genes specified, to pass to cluster comparison plots
@@ -299,13 +285,27 @@ export default function ExploreDisplayTabs({
299285 window . SCP . exploreInfo = exploreInfo
300286
301287 /** helper function so that StudyGeneField doesn't have to see the full exploreParams object */
302- function searchGenes ( genes ) {
288+ function queryFn ( queries ) {
289+ const isPathway = getIsPathway ( queries [ 0 ] )
303290 // also unset any selected gene lists or ideogram files
304- const newParams = { genes, geneList : '' , ideogramFileId : '' }
305- if ( genes . length < 2 ) {
306- // and unset the consensus if there are no longer 2+ genes
307- newParams . consensus = ''
291+ const newParams = { geneList : '' , ideogramFileId : '' }
292+ if ( isPathway ) {
293+ newParams . pathway = queries [ 0 ]
294+ newParams [ 'genes' ] = [ ]
295+ } else {
296+ newParams . genes = queries
297+ newParams [ 'pathway' ] = ''
298+
299+ if ( queries . length < 2 ) {
300+ // and unset the consensus if there are no longer 2+ genes
301+ newParams . consensus = ''
302+ }
308303 }
304+
305+ if ( exploreParams ?. label !== '' ) {
306+ newParams . label = exploreParams . label
307+ }
308+
309309 updateExploreParams ( newParams )
310310 }
311311
@@ -320,7 +320,7 @@ export default function ExploreDisplayTabs({
320320 exploreInfo &&
321321 exploreInfo . taxonNames . length === 1 &&
322322 exploreParams . genes . length === 1 &&
323- ! isGeneList
323+ ! isGeneList && ! isPathway
324324 ) {
325325 showRelatedGenesIdeogram = true
326326 currentTaxon = exploreInfo . taxonNames [ 0 ]
@@ -516,25 +516,38 @@ export default function ExploreDisplayTabs({
516516 return { main, side }
517517 }
518518
519+ let queries
520+ if ( exploreParams . pathway !== '' ) {
521+ queries = [ exploreParams . pathway ]
522+ } else {
523+ queries = exploreParams . genes
524+ }
525+
526+ // eslint-disable-next-line no-unused-vars
527+ const [ _ , selectedAnnotation ] = getSelectedClusterAndAnnot ( exploreInfo , exploreParams )
528+
519529 return (
520530 < >
521531 { /* Render top content for Explore view, i.e. gene search box and plot tabs */ }
522532 < div className = "row position-forward" >
523533 < div className = "col-md-5" >
524534 < div className = "flexbox" >
525- < StudyGeneField genes = { exploreParams . genes }
526- searchGenes = { searchGenes }
535+ < StudyGeneField
536+ queries = { queries }
537+ queryFn = { queryFn }
527538 allGenes = { exploreInfo ? exploreInfo . uniqueGenes : [ ] }
528539 isLoading = { ! exploreInfo }
529- speciesList = { exploreInfo ? exploreInfo . taxonNames : [ ] } />
540+ speciesList = { exploreInfo ? exploreInfo . taxonNames : [ ] }
541+ selectedAnnotation = { selectedAnnotation }
542+ />
530543 { // show if this is gene search || gene list
531- ( isGene || isGeneList || hasIdeogramOutputs ) &&
544+ ( isGene || isGeneList || hasIdeogramOutputs || isPathway ) &&
532545 < OverlayTrigger placement = "top" overlay = {
533546 < Tooltip id = "back-to-cluster-view" > { 'Return to cluster view' } </ Tooltip >
534547 } >
535548 < button className = "action fa-lg"
536549 aria-label = "Back arrow"
537- onClick = { ( ) => searchGenes ( [ ] ) } >
550+ onClick = { ( ) => queryFn ( [ ] ) } >
538551 < FontAwesomeIcon icon = { faArrowLeft } />
539552 </ button >
540553 </ OverlayTrigger >
@@ -559,7 +572,7 @@ export default function ExploreDisplayTabs({
559572 taxon = { currentTaxon }
560573 target = { `.${ plotContainerClass } ` }
561574 genesInScope = { exploreInfo . uniqueGenes }
562- searchGenes = { searchGenes }
575+ queryFn = { queryFn }
563576 speciesList = { exploreInfo . taxonNames }
564577
565578 studyAccession = { studyAccession }
@@ -666,6 +679,17 @@ export default function ExploreDisplayTabs({
666679 />
667680 </ div >
668681 }
682+ { enabledTabs . includes ( 'pathway' ) &&
683+ < div className = { shownTab === 'pathway' ? '' : 'hidden' } >
684+ < Pathway
685+ studyAccession = { studyAccession }
686+ { ... exploreParamsWithDefaults }
687+ labels = { getEligibleLabels ( exploreParamsWithDefaults , exploreInfo ) }
688+ dimensions = { getPlotDimensions ( { showViewOptionsControls, showDifferentialExpressionTable } ) }
689+ queryFn = { queryFn }
690+ />
691+ </ div >
692+ }
669693 { enabledTabs . includes ( 'geneListHeatmap' ) &&
670694 < div className = { shownTab === 'geneListHeatmap' ? '' : 'hidden' } >
671695 < GeneListHeatmap
@@ -726,7 +750,7 @@ export default function ExploreDisplayTabs({
726750 clearExploreParams = { clearExploreParams }
727751 exploreParamsWithDefaults = { exploreParamsWithDefaults }
728752 routerLocation = { routerLocation }
729- searchGenes = { searchGenes }
753+ queryFn = { queryFn }
730754 countsByLabelForDe = { countsByLabelForDe }
731755 setShowUpstreamDifferentialExpressionPanel = { setShowUpstreamDifferentialExpressionPanel }
732756 showDifferentialExpressionPanel = { showDifferentialExpressionPanel }
@@ -765,6 +789,7 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
765789 const numGenes = exploreParams ?. genes ?. length
766790 const isMultiGene = numGenes > 1
767791 const isGene = exploreParams ?. genes ?. length > 0
792+ const isPathway = exploreParams ?. pathway && exploreParams . pathway !== ''
768793 const isConsensus = ! ! exploreParams . consensus
769794 const hasClusters = exploreInfo && exploreInfo . clusterGroupNames . length > 0
770795 const hasSpatialGroups = exploreParams . spatialGroups ?. length > 0
@@ -783,6 +808,8 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
783808
784809 if ( isGeneList ) {
785810 enabledTabs = [ 'geneListHeatmap' ]
811+ } else if ( isPathway ) {
812+ enabledTabs = [ 'pathway' ]
786813 } else if ( isGene ) {
787814 if ( isMultiGene ) {
788815 if ( isConsensus ) {
@@ -838,5 +865,5 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
838865 disabledTabs = [ ]
839866 }
840867
841- return { enabledTabs, disabledTabs, isGeneList, isGene, isMultiGene, hasIdeogramOutputs }
868+ return { enabledTabs, disabledTabs, isGeneList, isGene, isPathway , isMultiGene, hasIdeogramOutputs }
842869}
0 commit comments