@@ -13,9 +13,10 @@ 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'
@@ -29,6 +30,7 @@ import PlotTabs from './PlotTabs'
2930import {
3031 initCellFaceting , filterCells , getFacetsParam , parseFacetsParam
3132} from '~/lib/cell-faceting'
33+ import { getIsPathway } from '~/lib/search-utils'
3234
3335/** Get the selected clustering and annotation, or their defaults */
3436export function getSelectedClusterAndAnnot ( exploreInfo , exploreParams ) {
@@ -286,7 +288,7 @@ export default function ExploreDisplayTabs({
286288 const [ filterErrorText , setFilterErrorText ] = useState ( null )
287289
288290 const {
289- enabledTabs, disabledTabs, isGeneList, isGene, isMultiGene, hasIdeogramOutputs
291+ enabledTabs, disabledTabs, isGeneList, isGene, isPathway , isMultiGene, hasIdeogramOutputs
290292 } = getEnabledTabs ( exploreInfo , exploreParamsWithDefaults , cellFaceting )
291293
292294 // exploreParams object without genes specified, to pass to cluster comparison plots
@@ -299,13 +301,27 @@ export default function ExploreDisplayTabs({
299301 window . SCP . exploreInfo = exploreInfo
300302
301303 /** helper function so that StudyGeneField doesn't have to see the full exploreParams object */
302- function searchGenes ( genes ) {
304+ function queryFn ( queries ) {
305+ const isPathway = getIsPathway ( queries [ 0 ] )
303306 // 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 = ''
307+ const newParams = { geneList : '' , ideogramFileId : '' }
308+ if ( isPathway ) {
309+ newParams . pathway = queries [ 0 ]
310+ newParams [ 'genes' ] = [ ]
311+ } else {
312+ newParams . genes = queries
313+ newParams [ 'pathway' ] = ''
314+
315+ if ( queries . length < 2 ) {
316+ // and unset the consensus if there are no longer 2+ genes
317+ newParams . consensus = ''
318+ }
319+ }
320+
321+ if ( exploreParams ?. label !== '' ) {
322+ newParams . label = exploreParams . label
308323 }
324+
309325 updateExploreParams ( newParams )
310326 }
311327
@@ -320,7 +336,7 @@ export default function ExploreDisplayTabs({
320336 exploreInfo &&
321337 exploreInfo . taxonNames . length === 1 &&
322338 exploreParams . genes . length === 1 &&
323- ! isGeneList
339+ ! isGeneList && ! isPathway
324340 ) {
325341 showRelatedGenesIdeogram = true
326342 currentTaxon = exploreInfo . taxonNames [ 0 ]
@@ -516,25 +532,33 @@ export default function ExploreDisplayTabs({
516532 return { main, side }
517533 }
518534
535+ let queries
536+ if ( exploreParams . pathway !== '' ) {
537+ queries = [ exploreParams . pathway ]
538+ } else {
539+ queries = exploreParams . genes
540+ }
541+
519542 return (
520543 < >
521544 { /* Render top content for Explore view, i.e. gene search box and plot tabs */ }
522545 < div className = "row position-forward" >
523546 < div className = "col-md-5" >
524547 < div className = "flexbox" >
525- < StudyGeneField genes = { exploreParams . genes }
526- searchGenes = { searchGenes }
548+ < StudyGeneField
549+ queries = { queries }
550+ queryFn = { queryFn }
527551 allGenes = { exploreInfo ? exploreInfo . uniqueGenes : [ ] }
528552 isLoading = { ! exploreInfo }
529553 speciesList = { exploreInfo ? exploreInfo . taxonNames : [ ] } />
530554 { // show if this is gene search || gene list
531- ( isGene || isGeneList || hasIdeogramOutputs ) &&
555+ ( isGene || isGeneList || hasIdeogramOutputs || isPathway ) &&
532556 < OverlayTrigger placement = "top" overlay = {
533557 < Tooltip id = "back-to-cluster-view" > { 'Return to cluster view' } </ Tooltip >
534558 } >
535559 < button className = "action fa-lg"
536560 aria-label = "Back arrow"
537- onClick = { ( ) => searchGenes ( [ ] ) } >
561+ onClick = { ( ) => queryFn ( [ ] ) } >
538562 < FontAwesomeIcon icon = { faArrowLeft } />
539563 </ button >
540564 </ OverlayTrigger >
@@ -559,7 +583,7 @@ export default function ExploreDisplayTabs({
559583 taxon = { currentTaxon }
560584 target = { `.${ plotContainerClass } ` }
561585 genesInScope = { exploreInfo . uniqueGenes }
562- searchGenes = { searchGenes }
586+ queryFn = { queryFn }
563587 speciesList = { exploreInfo . taxonNames }
564588
565589 studyAccession = { studyAccession }
@@ -666,6 +690,17 @@ export default function ExploreDisplayTabs({
666690 />
667691 </ div >
668692 }
693+ { enabledTabs . includes ( 'pathway' ) &&
694+ < div className = { shownTab === 'pathway' ? '' : 'hidden' } >
695+ < Pathway
696+ studyAccession = { studyAccession }
697+ { ... exploreParamsWithDefaults }
698+ labels = { getEligibleLabels ( exploreParamsWithDefaults , exploreInfo ) }
699+ dimensions = { getPlotDimensions ( { showViewOptionsControls, showDifferentialExpressionTable } ) }
700+ queryFn = { queryFn }
701+ />
702+ </ div >
703+ }
669704 { enabledTabs . includes ( 'geneListHeatmap' ) &&
670705 < div className = { shownTab === 'geneListHeatmap' ? '' : 'hidden' } >
671706 < GeneListHeatmap
@@ -726,7 +761,7 @@ export default function ExploreDisplayTabs({
726761 clearExploreParams = { clearExploreParams }
727762 exploreParamsWithDefaults = { exploreParamsWithDefaults }
728763 routerLocation = { routerLocation }
729- searchGenes = { searchGenes }
764+ queryFn = { queryFn }
730765 countsByLabelForDe = { countsByLabelForDe }
731766 setShowUpstreamDifferentialExpressionPanel = { setShowUpstreamDifferentialExpressionPanel }
732767 showDifferentialExpressionPanel = { showDifferentialExpressionPanel }
@@ -765,6 +800,7 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
765800 const numGenes = exploreParams ?. genes ?. length
766801 const isMultiGene = numGenes > 1
767802 const isGene = exploreParams ?. genes ?. length > 0
803+ const isPathway = exploreParams ?. pathway && exploreParams . pathway !== ''
768804 const isConsensus = ! ! exploreParams . consensus
769805 const hasClusters = exploreInfo && exploreInfo . clusterGroupNames . length > 0
770806 const hasSpatialGroups = exploreParams . spatialGroups ?. length > 0
@@ -783,6 +819,8 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
783819
784820 if ( isGeneList ) {
785821 enabledTabs = [ 'geneListHeatmap' ]
822+ } else if ( isPathway ) {
823+ enabledTabs = [ 'pathway' ]
786824 } else if ( isGene ) {
787825 if ( isMultiGene ) {
788826 if ( isConsensus ) {
@@ -838,5 +876,5 @@ export function getEnabledTabs(exploreInfo, exploreParams, cellFaceting) {
838876 disabledTabs = [ ]
839877 }
840878
841- return { enabledTabs, disabledTabs, isGeneList, isGene, isMultiGene, hasIdeogramOutputs }
879+ return { enabledTabs, disabledTabs, isGeneList, isGene, isPathway , isMultiGene, hasIdeogramOutputs }
842880}
0 commit comments