Git Product home page Git Product logo

Comments (7)

Hua-Zhou avatar Hua-Zhou commented on August 21, 2024

Following PLINK convention, true refers to a copy of A2 allele. When converting to real numbers for analysis purpose, we almost always want the real number to be minor allele count. That’s how the convert method works. It first figures out which is the minor allele for each column, then translate the minor allele counts into real number. In your example, the first SNP has 6 A1 allele and 3 A2 allele, so A2 is the minor allele. Therefore first column of Z is the A1 counts. Similar for other columns.

On Jun 17, 2016, at 6:08 PM, Kevin [email protected] wrote:

Shouldn't a SnpArray element (true, true) map to floating point 2.0 and (false, false) to floating point 0.0? Currently the default convert to a Matrix{Float64} flips them. There appears to be no way for the user to convert to Matrix{Float64} with a specification for minor_allele, unlike convert for the Boolean tuples (currently line 150 of SnpArrays.jl).

Minimal working example:

srand(2016);
z = SnpArray(rand(0:2, 5, 3));
Z = convert(Matrix{Float64}, z);
display(z)
display(Z)
Output for z:

5x3 SnpArrays.SnpArray{2}:
(false,true) (false,true) (true,true)
(false,false) (true,true) (true,true)
(true,true) (true,true) (true,true)
(true,true) (false,true) (false,true)
(false,true) (false,true) (false,true)
Output for Z:

5x3 Array{Float64,2}:
1.0 1.0 0.0
2.0 0.0 0.0
0.0 0.0 0.0
0.0 1.0 1.0
1.0 1.0 1.0

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub #3, or mute the thread https://github.com/notifications/unsubscribe/AEwHsbPqFvXInLmMcjmvO1FJmJ4PEMLqks5qM0T5gaJpZM4I41hv.

from snparrays.jl.

klkeys avatar klkeys commented on August 21, 2024

But per Issue #2, this renders default matrix multiplication inconsistent. For simplicity, let us neither center nor scale the multiplication. Continuing the aforementioned MWE:

y = ones(3);
x1 = z.A1*y + z.A2*y;
x2 = Z*y;
display(x1)
display(x2)

Output for x1:

5-element Array{Float64,1}:
 4.0
 4.0
 6.0
 4.0
 3.0

Output for x2:

5-element Array{Float64,1}:
 2.0
 2.0
 0.0
 2.0
 3.0

from snparrays.jl.

klkeys avatar klkeys commented on August 21, 2024

Wait, your previous comment is backwards. If true represents a copy of the A2 allele, then column 1 of z has six A2 alleles and three A1 alleles. Then A1 is the minor allele, which explains the behavior of convert. But this is still inconsistent since, as you say, PLINK conventions count copies of the A2 allele, and here convert explicitly breaks that convention.

from snparrays.jl.

Hua-Zhou avatar Hua-Zhou commented on August 21, 2024

Your are right my previous comment is backwards. In your first column there are 3 A1 alleles and 6 A2 alleles, therefore A1 is the minor allele. Therefore convert method translated to count of A1 alleles. I would keep the convention that convert always translates to minor allele counts (versus the A2 allele count) since it’s the most use cases.

On Jun 20, 2016, at 5:19 PM, Kevin [email protected] wrote:

Wait, your previous comment is backwards. If true represents a copy of the A2 allele, then column 1 of z has six A2 alleles and three A1 alleles. Then A1 is the minor allele, which explains the behavior of convert. But this is still inconsistent since, as you say, PLINK conventions count copies of the A2 allele, and here convert explicitly breaks that convention.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #3 (comment), or mute the thread https://github.com/notifications/unsubscribe/AEwHsT9qw4ZyioBLfhYk271kyrPa2_Vlks5qNwPxgaJpZM4I41hv.

from snparrays.jl.

Hua-Zhou avatar Hua-Zhou commented on August 21, 2024

We should keep the convert/copy methods as it is (translating to minor allele counts). When overloading the multiplication methods, a BitVector of minor_allele should be utilized for correct implementation if we intend to multiply the minor allele count matrix.

On Jun 18, 2016, at 7:45 PM, Kevin [email protected] wrote:

But per Issue #2 #2, this renders multiplication inconsistent. For simplicity, let us neither center nor scale the multiplication. Continuing the aforementioned MWE:

y = ones(3);
x1 = z.A1_y + z.A2_y;
x2 = Z*y;
display(x1)
display(x2)
Output for x1:

5-element Array{Float64,1}:
4.0
4.0
6.0
4.0
3.0
Output for x2:

5-element Array{Float64,1}:
2.0
2.0
0.0
2.0
3.0

You are receiving this because you commented.
Reply to this email directly, view it on GitHub #3 (comment), or mute the thread https://github.com/notifications/unsubscribe/AEwHsdvi-c4J844-9NwgXRLIuboY8Q7mks5qNIM3gaJpZM4I41hv.

from snparrays.jl.

klkeys avatar klkeys commented on August 21, 2024

Currently there is no convert method with an argument to specify minor alleles.

from snparrays.jl.

Hua-Zhou avatar Hua-Zhou commented on August 21, 2024

Convert figures out which is the minor allele itself so doesn’t need the minor allele input. Multiplication methods should take that information though.

On Jun 21, 2016, at 11:23 AM, Kevin [email protected] wrote:

Currently there is no convert method with an argument to specify minor alleles.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #3 (comment), or mute the thread https://github.com/notifications/unsubscribe/AEwHsQbg_IElzYK0c_o3FASriC0bMWb9ks5qOAHygaJpZM4I41hv.

from snparrays.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.