Skip to content

Commit

Permalink
runing prs on qc=true 23andme and pgs entries
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenasandoval88 committed Aug 29, 2024
1 parent f37ac87 commit 73429ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ <h4 class="hero_title">Diseasome</h3>
<!-- Tab content -->
<!-- <div class="tab">
</div> -->
<div id=prsDiv></div><br>

<div class="tab">
<button id = "prsButton" class="tablinks" onclick="openCity(event, 'PRS')">Calculate PRS</button>
<button class="tablinks" onclick="openCity(event, 'PGS catalog')">Explore the PGS catalog</button>
<button class="tablinks" onclick="openCity(event, 'OpenSNP')">Explore OpenSNP</button>
<!-- <button id = "prsButton" class="tablinks" onclick="openCity(event, 'PRS')">Calculate PRS</button> -->
</div>
<div id = "selection"></div>
<div id=prsDiv></div><br>

<div id = "selection"></div>


<!-- PRS ------------------------------------------>
Expand Down
23 changes: 13 additions & 10 deletions sdk/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const ui = async function (targetDiv) {

dt.pgs = {}

let pgsIds = (await (getPgs.idsFromCategory(category))).sort().slice(0, 3)
let pgsIds = (await (getPgs.idsFromCategory(category))).sort().slice(3,6)
console.log("pgsIds", pgsIds)
let pgsTxts = await Promise.all( pgsIds.map(async x => {
let res = await getPgs.loadScoreHm(x)
Expand All @@ -146,11 +146,13 @@ const ui = async function (targetDiv) {
dt.pgs.ids = pgsIds
dt.pgs.txts = pgsTxts

//calculate prs
//calculate prs
console.log("Calculating PRS scores!")

let data = {}
data.PGS = dt.pgs.txts
data.my23 = dt.users.txts
console.log("data",data)
data.my23 = dt.users.txts.filter(x=> x.qc == true)//x.year > "2011" &
console.log("data",dt.users.txts.filter(x=> x.qc == true))

let prsDt = PRS.calc(data)
dt.prs = await prsDt
Expand Down Expand Up @@ -194,17 +196,18 @@ const getUsersByPhenotypeId = async function (phenoId, keysLen, maxKeys) {
}

let userIds = users.users.map(x => x.user_id)
console.log("userIds",users)
// console.log("userIds",users)
// get users with phenotype data (even those without genotype data)
const userIds2 = allUsers.filter(({
id
}) => userIds.includes(id));
let cleanUsers
if (userIds2.length < 6) {
let maxUsers = 8
if (userIds2.length < maxUsers) {
cleanUsers = getUsersByType("23andme", userIds2)
} else {
cleanUsers = ( getUsersByType("23andme", userIds2.slice(4, 15))).slice(0,4)
console.log("Warning: user txts for phenotypeID", phenoId, "> 6. First 6 files used.")
cleanUsers = ( getUsersByType("23andme", userIds2.slice(6, 19))).slice(0,maxUsers)
console.log("Warning: user txts for phenotypeID", phenoId, "> 7. First 6 files used.")
}
// get 23 and me texts from urls using getTxts function
let snpTxts = await getTxts(cleanUsers, keysLen, maxKeys)
Expand All @@ -230,7 +233,7 @@ const parseTxts = async function (txt, usersData) {
obj.year = rows[0].split(/\r?\n|\r|\n/g)[0].slice(-4)
obj.qc = rows[0].substring(0, 37) == '# This data file generated by 23andMe'
obj.dt = rows.slice(n)
obj.variant_number = obj.dt.length()
obj.variant_number = obj.dt.length

obj.dt = obj.dt.map((r, i) => {
r = r.split('\t')
Expand Down Expand Up @@ -278,7 +281,7 @@ const getTxts = async function (usersData) {

// filter users without 23andme data (type = "23andme")
const getUsersByType = function (type, userIds) {
console.log("getUsersByType fun users",userIds)
// console.log("getUsersByType fun users",userIds)

let arr = []
userIds.filter(row => row.genotypes.length > 0).map(dt => {
Expand Down

0 comments on commit 73429ee

Please sign in to comment.