Skip to content

Commit

Permalink
user 23andme with new chips
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenasandoval88 committed Apr 5, 2024
1 parent 959aebc commit 307a829
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 83 deletions.
19 changes: 12 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ <h4 class="hero_title">Diseasome</h3>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'PGS catalog')">PGS catalog</button>
<button class="tablinks" onclick="openCity(event, 'OpenSNP')">OpenSNP</button>
<button class="tablinks" onclick="openCity(event, 'PRS')">PRS</button>
<button id = "prsButton" class="tablinks" onclick="openCity(event, 'PRS')">PRS</button>
</div>
<div id = "selection"></div>


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


<div id="PRS" class="tabcontent">
Expand All @@ -91,9 +92,15 @@ <h3>PRS</h3>
personal devices, including smartphones, establishing the feasibility of privately calculating personal risk
scores with up to a few thousand reference genetic variations and from the full 23andMe SNP data file
(compressed or not).</p>

<div id=prsDiv>prsDiv</div>


</div>

<!-- 23 and me -->


<!-- 23 and me ------------------------------------------>

<div id="OpenSNP" class="tabcontent">
<h3>OpenSNP</h3>
Expand Down Expand Up @@ -161,15 +168,12 @@ <h6 id="pieHeader"></h6>
</div>
<!-- --------------------->
<div id="Traits" class="tabcontent">
<h6 style="color: rgb(6, 137, 231);">Or select a PGS trait below:</h6>
<h6 style="color: rgb(6, 137, 231);">Select a PGS trait 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>
</div>
<div id="secondBarTraits"></div>
<!--
<div class='graph-container'>
</div> -->
<div id="secondBarTraitsButton"></div>

<div id="betassecondBarTraitsButton"></div>
Expand All @@ -178,6 +182,7 @@ <h6 style="color: rgb(6, 137, 231);">Or select a PGS trait below:</h6>
</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>
Expand Down
31 changes: 29 additions & 2 deletions sdk/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ functions.get23 = async function(urls) {
let arr23Txts = []
for (let i = 0; i < urls.length; i++) {
let user = await openSnpDbUsers.getItem(urls[i]);
console.log(i)

if (user == null) {
let url2 = 'https://corsproxy.io/?' + urls[i]
Expand All @@ -78,14 +79,40 @@ functions.get23 = async function(urls) {
}
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 parse23(user, urls[i])
let parsedUser = await functions.parse23(user, 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) {
// normally info is the file name
let obj = {}
let rows = txt.split(/[\r\n]+/g)
obj.txt = txt
obj.url = url

let n = rows.filter(r => (r[0] == '#')).length
obj.meta = rows.slice(0, n - 1).join('\r\n')
obj.cols = rows[n - 1].slice(2).split(/\t/)
obj.dt = rows.slice(n)
obj.dt = obj.dt.map((r, i) => {
r = r.split('\t')
r[2] = parseInt(r[2])
// position in the chr
r[4] = i
return r
})
return obj
}



// FUNCTIONS------------------------------------------------------------------------
functions.downloadBlob = function(content, filename, contentType) {
// Create a blob
Expand Down Expand Up @@ -201,7 +228,7 @@ functions.traitsData = async function(traits) {
return dt
}
//--------------------------------------
functions.getAllPgsIdsByCategory = function(trait) {
functions.getAllPgsIdsByCategory = async function(trait) {
let traitFilesArr = []
let pgsIds = []
// get trait files that match selected trait from drop down
Expand Down
Loading

0 comments on commit 307a829

Please sign in to comment.