Skip to content

Commit

Permalink
added prs plot
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenasandoval88 committed Apr 10, 2024
1 parent 307a829 commit 5c6605d
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 246 deletions.
23 changes: 21 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ <h3>PRS</h3>
(compressed or not).</p>

<div id=prsDiv>prsDiv</div>
<div id=prsButton></div>


</div>
Expand Down Expand Up @@ -133,8 +134,12 @@ <h3>The Polygenic Score (PGS) Catalog</h3>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'Categories', true)">Categories</button>
<button class="tablinks" onclick="openCity(event, 'Traits', true)">Traits</button>
<button class="tablinks" onclick="openCity(event, 'EFO_ids', true)">EFO_ids</button>

</div>

<!-- --------------------->

<div id="Categories" class="tabcontent">

<h6 style="color: rgb(6, 137, 231);">Select a PGS category below:</h6>
Expand Down Expand Up @@ -168,7 +173,7 @@ <h6 id="pieHeader"></h6>
</div>
<!-- --------------------->
<div id="Traits" class="tabcontent">
<h6 style="color: rgb(6, 137, 231);">Select a PGS trait below:</h6>
<h6 style="color: rgb(6, 137, 231);">Select a PGS category below:</h6>
<div id="topBarTraits"></div>
<div class="spinner-border m-5" style="display: none;" role="status" id="spinner3">
<span class="visually-hidden">Loading...</span>
Expand All @@ -180,10 +185,24 @@ <h6 style="color: rgb(6, 137, 231);">Select a PGS trait below:</h6>
<div id="betassecondBarTraits"></div>
</div>
</div>

<!-- --------------------->

<div id="EFO_ids" class="tabcontent">

<h6 style="color: rgb(6, 137, 231);">Select an EFO id below:</h6>
<div id="topBarEFO_ids"></div>
<p id="description1" style="font-size:10px;color:blue"></p>


</div>
<button id="plotbetasButton"></button>

<div id="plotbetas">plotbetas</div>

<!-- scripts----------------------------------------------->
<script src="tabs.js"></script>
<script type="module" src="sdk/prs.js"></script>

<script type="module" src="sdk/sdk.js"></script>
<script type="module" src="sdk/main.js"></script>
<script type="module" src="sdk/plots.js"></script>
Expand Down
17 changes: 9 additions & 8 deletions sdk/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,38 @@ functions.filterUsers = async function(type, users) {
}


functions.get23 = async function(urls) {
functions.get23 = async function(usersData) {
let arr23Txts = []
// console.log(",usersData.map(x=> x.phenotypes[Type II Diabetes])",usersData.map(x=> x.phenotypes["Type II Diabetes"]))//.phenotypes["Type II Diabetes"]))
let urls = usersData.map( x => x["genotype.download_url"]).slice(128,150)
console.log("# of users: ",urls.length)
for (let i = 0; i < urls.length; i++) {
let user = await openSnpDbUsers.getItem(urls[i]);
console.log(i)
console.log("user #",i,"------")

if (user == null) {
let url2 = 'https://corsproxy.io/?' + urls[i]
user = (await (await fetch(url2)).text())
openSnpDbUsers.setItem(urls[i], user);
}
if (user.substring(0, 37) == '# This data file generated by 23andMe') {
//console.log("This is a valid 23andMe file:", user.substring(0, 37))
let parsedUser = await functions.parse23(user, urls[i])
console.log("This is a valid 23andMe file:", user.substring(0, 37))
let parsedUser = await functions.parse23(user, usersData[i])//urls[i])
arr23Txts.push(parsedUser)
} else {
console.log("ERROR:This is NOT a valid 23andMe file:", user.substring(0, 37))
}
}
console.log("arr23Txts",arr23Txts)
return arr23Txts
}

// create 23andme obj and data --------------------------
functions.parse23 = async function (txt, url) {
functions.parse23 = async function (txt, usersData) {
// normally info is the file name
let obj = {}
let rows = txt.split(/[\r\n]+/g)
obj.txt = txt
obj.url = url
obj.openSnp = usersData

let n = rows.filter(r => (r[0] == '#')).length
obj.meta = rows.slice(0, n - 1).join('\r\n')
Expand Down Expand Up @@ -278,7 +280,6 @@ functions.getscoreFiles = async function(pgsIds) {


const traitFiles = (await functions.fetchAll2('https://www.pgscatalog.org/rest/trait/all')).flatMap(x => x)
functions.removeLocalStorageValues('request', pgs)

export {
functions
Expand Down
Loading

0 comments on commit 5c6605d

Please sign in to comment.