-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-boolean results e.g. percentages #6
Comments
Naive early morning attempt but here are a few possible APIs, slowly getting sugarier var test = gql.percentage([
{test: gql.exact('rs6625163', 'AA'), magnitude: 1.2},
{test: gql.exact('rs1160312', 'AA'), magnitude: 2},
{test: gql.exact('rs1160312', 'AG'), magnitude: 2},
{test: gql.exact('rs201571', 'TT'), magnitude: 2},
{test: gql.exact('rs6036025', 'GG'), magnitude: 1.2}
]);
test(someDNA); // 85 // gql.magnitude would have to error when being used outside of a percentage
// also kind of breaks the whole "everything is a function" thing
// also magnitude should probably be the second arg here but i was too lazy to change the code
var test = gql.percentage([
gql.magnify(1.2, gql.exact('rs6625163', 'AA')),
gql.magnify(2, gql.exact('rs1160312', 'AA')),
gql.magnify(2, gql.exact('rs1160312', 'AG')),
gql.magnify(2, gql.exact('rs201571', 'TT')),
gql.magnify(1.2, gql.exact('rs6036025', 'GG'))
]);
test(someDNA); // 85 // every gql test function would have a magnitude fn that returns a clone of the fn with a new _magnitude property that percentage knows about
// this would allow stuff like gql.percentage([isMale.magnitude(2)])
// but it also limits usage of vanilla functions without wrapping them or adding the _magnitude manually
var test = gql.percentage([
gql.exact('rs6625163', 'AA').magnitude(1.2),
gql.exact('rs1160312', 'AA').magnitude(2),
gql.exact('rs1160312', 'AG').magnitude(2),
gql.exact('rs201571', 'TT').magnitude(2),
gql.exact('rs6036025', 'GG').magnitude(1.2)
]);
test(someDNA); // 85 We should think about how this plays into being a part of other queries. If (for example) the isMale module is not a boolean and instead returns a percentage a module that depends on it could do what amounts to gql.and([
function(dna){
return isMale(dna) >= 85;
},
otherStuff...
]); |
API-wise my preference is option 3 (although it could be a bit hairy to implement), then 2. As a side note, I’d prefer to return actual percentages, e.g. |
With the new update this should be fixed - you can calculate this however you want now, the dna is just an object. |
http://www.snpedia.com/index.php/Gs122/criteria (I’m working on a repo for this one btw) is an example of a genoset for which each criterium has a certain weight that contributes to the end result.
The number e.g. the
1.2
followingrs6625163(A;A)
is the magnitude value as provided by SNPedia.Should there be a way to give each criterium a weight in gql queries? If so, any ideas on what the API should look like? Discuss.
The text was updated successfully, but these errors were encountered: