Skip to content

Commit

Permalink
added TF Motifs tab
Browse files Browse the repository at this point in the history
  • Loading branch information
NishiPhalke committed Oct 30, 2023
1 parent 9bddd65 commit 27bfe6e
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 6 deletions.
4 changes: 3 additions & 1 deletion screen2.0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"dependencies": {
"@apollo/client": "alpha",
"bpnet-ui": "^0.2.9",
"@apollo/experimental-nextjs-app-support": "^0.4.3",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
Expand Down Expand Up @@ -65,7 +66,8 @@
"tailwindcss": "3.3.5",
"typescript": "5.2.2",
"umms-gb": "^3.10.0",
"uuid": "^9.0.0"
"uuid": "^9.0.0",
"logots-react": "latest"
},
"devDependencies": {
"file-loader": "^6.2.0",
Expand Down
5 changes: 4 additions & 1 deletion screen2.0/src/app/search/ccredetails/ccredetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TfIntersection } from "./tfintersection"
import { FunctionData } from "./functionaldata"
import Rampage from "./rampage"
import { GeneExpression } from "./gene-expression"
import { TfSequenceFeatures} from "../gbview/tfsequencefeatures"

//Passing these props through this file could be done with context to reduce prop drilling
type CcreDetailsProps = {
Expand All @@ -22,6 +23,7 @@ type CcreDetailsProps = {
}

export const CcreDetails: React.FC<CcreDetailsProps> = ({ accession, region, globals, assembly, genes, page }) => {
console.log("region", region)
return (
<>
<Stack direction="row" justifyContent={"space-between"} alignItems={"baseline"}>
Expand Down Expand Up @@ -55,7 +57,8 @@ export const CcreDetails: React.FC<CcreDetailsProps> = ({ accession, region, glo
{page === 4 && <Ortholog accession={accession} assembly={assembly} />}
{page === 5 && <GeneExpression assembly={assembly} genes={genes} />}
{page === 6 && <FunctionData accession={accession} coordinates={{ chromosome: region.chrom, start: +region.start.toString().replace(/\D/g, ""), end: +region.end.toString().replace(/\D/g, "") }} assembly={assembly} />}
{assembly!=="mm10" && page === 7 && <Rampage gene={genes.distancePC[0].name} />}
{assembly!=="mm10" && page === 7 && <TfSequenceFeatures assembly={assembly} coordinates = {{ chromosome: region.chrom, start: +(region.start.replace(/\D/g, "")), end: +(region.end.replace(/\D/g, "")) }} />}
{assembly!=="mm10" && page === 8 && <Rampage gene={genes.distancePC[0].name} />}
</>
)
}
1 change: 1 addition & 0 deletions screen2.0/src/app/search/ccresearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export const CcreSearch = (props: { mainQueryParams: MainQueryParams, globals })

<StyledTab label="Associated Gene Expression" sx={{ alignSelf: "start" }} />
<StyledTab label="Functional Data" sx={{ alignSelf: "start" }} />
{props.mainQueryParams.assembly!=="mm10" && <StyledTab label="TF Motifs" sx={{ alignSelf: "start" }} />}
{props.mainQueryParams.assembly!=="mm10" && <StyledTab label="Associated RAMPAGE Signal" sx={{ alignSelf: "start" }} />}
</Tabs>
}
Expand Down
2 changes: 1 addition & 1 deletion screen2.0/src/app/search/gbview/genomebrowserview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const GenomeBrowserView: React.FC<GenomeBrowserViewProps> = (props) => {
<Grid2 container spacing={3} sx={{ mt: "1rem", mb: "1rem" }}>
<Grid2 xs={12} lg={12}>
<br />
<CytobandView innerWidth={1000} height={15} chromosome={coordinates.chromosome!} assembly={"hg38"} position={coordinates} />
<CytobandView innerWidth={1000} height={15} chromosome={coordinates.chromosome!} assembly={props.assembly!=="mm10" ?"hg38" : "mm10"} position={coordinates} />
<br />
<div style={{ textAlign: "center" }}>
<Controls onDomainChanged={onDomainChanged} domain={coordinates || props.coordinates} />
Expand Down
6 changes: 3 additions & 3 deletions screen2.0/src/app/search/gbview/tfmotiftrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export const TfMotifTrack = (props) => {

return (
<g>
<EmptyTrack height={40} width={props.width || 1400} text="TF Motif Occurences" transform="" id="" />
<EmptyTrack height={40} width={props.width || 1000} text="TF Motif Occurences" transform="" id="" />
<SquishBigBed
domain={props.coordinates}
svgRef={props.svgRef}
width={1000}
width={props.width}
rowHeight={20}
onHeightChanged={(x) => {
setHeight(x + 40)
Expand All @@ -52,7 +52,7 @@ export const TfMotifTrack = (props) => {
}}
/>
{settingsMousedOver && (
<rect width={props.width || 1400} height={height} transform="translate(0,0)" fill="#194023" fillOpacity={0.1} />
<rect width={props.width || 1000} height={height} transform="translate(0,0)" fill="#194023" fillOpacity={0.1} />
)}
<rect transform="translate(0,0)" height={height} width={40} fill="#ffffff" />
<rect
Expand Down
178 changes: 178 additions & 0 deletions screen2.0/src/app/search/gbview/tfsequencefeatures.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
"use client"
import React, { useMemo, useState, useRef, useCallback, useEffect } from "react"
import Grid2 from "../../../common/mui-client-wrappers/Grid2"
import { RulerTrack, GenomeBrowser } from "umms-gb"
import Controls from "./controls"
import { gql, useQuery } from "@apollo/client"
import CytobandView, { GenomicRange } from "./cytobandview"
import EGeneTracks from "./egenetracks"
import { client } from "../ccredetails/client"
import { TfMotifTrack } from "./tfmotiftrack"
import { DenseBigBed, EmptyTrack, FullBigWig } from "umms-gb"

type TfSequenceFeaturesProps = {
coordinates: {
start: number
end: number
chromosome?: string
}
assembly: string
}
const GENE_QUERY = gql`
query s($chromosome: String, $start: Int, $end: Int, $assembly: String!) {
gene(chromosome: $chromosome, start: $start, end: $end, assembly: $assembly) {
name
strand
transcripts {
name
strand
exons {
coordinates {
chromosome
start
end
}
}
coordinates {
chromosome
start
end
}
}
}
}
`
export type Transcript = {
id: string
name: string
strand: string
coordinates: GenomicRange
}
export type SNPQueryResponse = {
gene: {
name: string
strand: string
transcripts: Transcript[]
}[]
}
export function expandCoordinates(coordinates, l = 0) {
return {
chromosome: coordinates.chromosome,
start: coordinates.start - l < 0 ? 0 : coordinates.start - l,
end: coordinates.end + l,
}
}
const DATA_QUERY = `
query q($requests: [BigRequest!]!) {
bigRequests(requests: $requests) {
data
}
}
`

export const TfSequenceFeatures: React.FC<TfSequenceFeaturesProps> = (props) => {
const [data, setData] = useState([])
const [loading, setLoading] = useState(true)
const svgRef = useRef<SVGSVGElement>(null)
const expandedCoordinates = useMemo(() => expandCoordinates(props.coordinates), [props.coordinates])
const [coordinates, setCoordinates] = useState<GenomicRange>(expandedCoordinates)
useEffect(() => {
fetch("https://ga.staging.wenglab.org/graphql", {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query: DATA_QUERY,
variables: {
requests: [
{
url: "gs://gcp.wenglab.org/SCREEN/all-sites.sorted.formatted.bigBed",
chr1: coordinates.chromosome,
start: coordinates.start,
chr2: coordinates.chromosome,
end: coordinates.end
},
],
},
}),
})
.then((x) => x.json())
.then((x) => {
setData(x.data.bigRequests[0].data.filter((x) => x.name.split("$")[3] === "True"))
setLoading(false)
})
}, [coordinates])
console.log(data,'data')
const snpResponse = useQuery<SNPQueryResponse>(GENE_QUERY, {
variables: { ...coordinates, assembly: props.assembly },
fetchPolicy: "cache-and-network",
nextFetchPolicy: "cache-first",
client,
})

const groupedTranscripts = useMemo(
() =>
snpResponse.data?.gene.map((x) => ({
...x,
transcripts: x.transcripts.map((xx) => ({
...xx,
color: "#aaaaaa",
})),
})),
[snpResponse]
)
const onDomainChanged = useCallback(
(d: GenomicRange) => {
const chr = d.chromosome === undefined ? props.coordinates.chromosome : d.chromosome
const start = Math.round(d.start)
const end = Math.round(d.end)
if (end - start > 10) {
setCoordinates({ chromosome: chr, start, end })
}
},
[props.coordinates]
)
return (
<>
<Grid2 container spacing={3} sx={{ mt: "1rem", mb: "1rem" }}>
<Grid2 xs={12} lg={12}>
<br />
<CytobandView innerWidth={1000} height={15} chromosome={coordinates.chromosome!} assembly={props.assembly!=="mm10"? "hg38": "mm10"} position={coordinates} />
<br />
<div style={{ textAlign: "center" }}>
<Controls onDomainChanged={onDomainChanged} domain={coordinates || props.coordinates} />
</div>
<br />
<br />
<GenomeBrowser
svgRef={svgRef}
domain={coordinates}
innerWidth={1400}
width="100%"
noMargin
onDomainChanged={(x) => {
if (Math.ceil(x.end) - Math.floor(x.start) > 10) {
setCoordinates({
chromosome: coordinates.chromosome,
start: Math.floor(x.start),
end: Math.ceil(x.end),
})
}
}}
>
<RulerTrack domain={coordinates} height={30} width={1400} />
<EGeneTracks
genes={groupedTranscripts || []}
expandedCoordinates={coordinates}
squish={true}
/>
{!loading && data && props.assembly!=="mm10" && <TfMotifTrack width={1400} data={data} svgRef={svgRef} coordinates={coordinates}/>}

</GenomeBrowser>
</Grid2>
</Grid2>
</>
)
}
62 changes: 62 additions & 0 deletions screen2.0/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,14 @@ batch@0.6.1:
resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16"
integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==

beautiful-react-hooks@^0.35.0:
version "0.35.0"
resolved "https://registry.yarnpkg.com/beautiful-react-hooks/-/beautiful-react-hooks-0.35.0.tgz#816664f9a9fcf0a944f08bacf897cb1e5e94edbb"
integrity sha512-EDjpQWskuK7ob+rfH/Xt6UpFA+vC+ARM1TYAWRgYWcjcaDCGFuc3q5Ko4WJQUcFP2cq9ps3GihUSqN+KfUwQdg==
dependencies:
lodash.debounce "^4.0.8"
lodash.throttle "^4.1.1"

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
Expand Down Expand Up @@ -1262,6 +1270,16 @@ body-parser@^1.20.1:
type-is "~1.6.18"
unpipe "1.0.0"

bpnet-ui@^0.2.9:
version "0.2.9"
resolved "https://registry.yarnpkg.com/bpnet-ui/-/bpnet-ui-0.2.9.tgz#58564c4a4956207d25176560bd175af742fc9ebe"
integrity sha512-LyPbcGDw8u0hk+SNBu2OnJMi3Vuf1l4ihOhafxfmNyatpK2Jqzf++0ldaJZ7zFnTNgU+k7VSQH92wT25Qnx7tw==
dependencies:
beautiful-react-hooks "^0.35.0"
jubilant-carnival "^0.4.0"
logots-react "^0.2.0"
use-http "^1.0.20"

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
Expand Down Expand Up @@ -3255,6 +3273,11 @@ jstransformer@1.0.0:
object.assign "^4.1.4"
object.values "^1.1.6"

jubilant-carnival@^0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/jubilant-carnival/-/jubilant-carnival-0.4.1.tgz#d459e5f9f8dd8cba1e6c8d08df4ec5aec535d823"
integrity sha512-J+u1mMB/g+FbWZZYPnjHDkePfhLfRucdBspf/ySaaCBVu9AbMB+6CI8vM9pkSXw6ZvnPLPlmzAJN6j5c6DPpbg==

jubilant-carnival@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/jubilant-carnival/-/jubilant-carnival-0.6.0.tgz#1d8b8b43ea6320ac3bd470044111750a56136ce8"
Expand Down Expand Up @@ -3365,6 +3388,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
Expand All @@ -3380,6 +3408,11 @@ lodash.merge@^4.6.2:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.throttle@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==

log-update@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/log-update/-/log-update-5.0.1.tgz#9e928bf70cb183c1f0c9e91d9e6b7115d597ce09"
Expand All @@ -3396,6 +3429,11 @@ logots-react@^0.1.6:
resolved "https://registry.yarnpkg.com/logots-react/-/logots-react-0.1.6.tgz#4d3632c1732b87780b1e25988ccbb0ae661ec966"
integrity sha512-6mSwtEBWlE5Zy8OFS4SKiNVYzdrn4fKP5HqeixdOcS+w6V1ndJzMjEwxInk+5WfbcjwxTNz2GF9gL9HzkMF+Cg==

logots-react@^0.2.0, logots-react@latest:
version "0.2.0"
resolved "https://registry.yarnpkg.com/logots-react/-/logots-react-0.2.0.tgz#2bb6ec7bff6757d9c2fbe7cb1d4c8886639c480a"
integrity sha512-bshaVy1XMQpNYQEVYt9v+rqFG4gQ4U++V41fckIDQsmJ9duQbfhXZTrwP9uBE886YEHmUd/0pYfRe0Lc+Aqprw==

loose-envify@^1.1.0, loose-envify@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
Expand Down Expand Up @@ -5253,6 +5291,11 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"

urs@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/urs/-/urs-0.0.8.tgz#8a0e0b792073cdb7eec926d08ab1e017ffab3f66"
integrity sha512-LaSSPpr91XrVA3vW2zPupw4K6DSQEDKdL4yQZX1mO2fpljIMpB5zctrjRvxLurelWSgKsHsCmfHNCImscryirQ==

use-deep-compare-effect@^1.4.0:
version "1.8.1"
resolved "https://registry.yarnpkg.com/use-deep-compare-effect/-/use-deep-compare-effect-1.8.1.tgz#ef0ce3b3271edb801da1ec23bf0754ef4189d0c6"
Expand All @@ -5261,11 +5304,30 @@ use-deep-compare-effect@^1.4.0:
"@babel/runtime" "^7.12.5"
dequal "^2.0.2"

use-http@^1.0.20:
version "1.0.28"
resolved "https://registry.yarnpkg.com/use-http/-/use-http-1.0.28.tgz#57323e5ddcb82b41543d4498db234e47a6700d4b"
integrity sha512-MWux13mGDBj+bzuTZJczDIjFu5r7D9eYrrKyKaCo+KFvoGRE9mpNHLK21pAJb2Sbdh/J85y5E4b2xR+IH2WOkg==
dependencies:
urs "^0.0.8"
use-ssr "^1.0.24"
utility-types "^3.10.0"

use-ssr@^1.0.24:
version "1.0.25"
resolved "https://registry.yarnpkg.com/use-ssr/-/use-ssr-1.0.25.tgz#c7f54b59d6e52db26749b1d4115a650101a190bd"
integrity sha512-VYF8kJKI+X7+U4XgGoUER2BUl0vIr+8OhlIhyldgSGE0KHMoDRXPvWeHUUeUktq7ACEOVLzXGq1+QRxcvtwvyQ==

util-deprecate@^1.0.1, util-deprecate@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

utility-types@^3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b"
integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==

utils-merge@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
Expand Down

0 comments on commit 27bfe6e

Please sign in to comment.