fastlmm / FaST-LMM

Python version of Factored Spectrally Transformed Linear Mixed Models
https://fastlmm.github.io/
Apache License 2.0
47 stars 11 forks source link

Issue with multiple phenotype files #20

Closed koa-planedin closed 3 years ago

koa-planedin commented 3 years ago

Hi there,

I am trying to use multiple phenotypes and have been getting the error 'NoneType' object is not subscriptable. I have used space and tab delimited files with and without column names without success.

I tried running:

import numpy as np
from fastlmm.association import single_snp
pheno_both =  "C:/Users/koapl/OneDrive/Desktop/data/double_pheno.txt"
bed_fn = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/Potri.001G385100.vcf.gz.bed"
results_df = single_snp(bed_fn, pheno_both, count_A1=False)

This is an example file: double_pheno.txt

Do you know what is causing this error and how I can fix it? My single phenotype files have been running without issue.

Thanks in advance, Koa

CarlKCarlK commented 3 years ago

Koa,

Thanks for using FaST-LMM and thanks for including the sample pheno file!

Your sample pheno file works fine for me. So, let's try:

Specifying the files readers explicitly like this:

import numpy as np from fastlmm.association import single_snp from pysnptools.snpreader import Pheno, Bed bed = Bed(r"C:/Users/koapl/OneDrive/Desktop/data/leaf-files/Potri.001G385100.vcf.gz.bed",count_A1=False) print(bed.shape) pheno = Pheno("C:/Users/koapl/OneDrive/Desktop/data/double_pheno.txt") print(pheno.shape) results_df = single_snp(bed, pheno, count_A1=False)

Also, please let me know what version of Python, fastlmm, pysnptools, and bed-reader you are using.

Yours, Carl

Carl Kadie, Ph.D. FaST-LMM & PySnpTools Teamhttps://fastlmm.github.io/ (Microsoft Research, retired) https://www.linkedin.com/in/carlk/

Join the FaST-LMM user discussion and announcement list via @.***?subject=Subscribe> (or use web sign uphttps://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman3%2Flists%2Ffastlmm-user.python.org&data=02%7C01%7C%7C13a5c33d7cd84cad5cdf08d7bba56e20%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637184191498409587&sdata=2CQWjQEwOpQol2rQ1eoyVTgY8WvInV8UH31Wtl68FzY%3D&reserved=0)

From: koa-planedin @.> Sent: Monday, July 12, 2021 2:10 PM To: fastlmm/FaST-LMM @.> Cc: Subscribed @.***> Subject: [fastlmm/FaST-LMM] Issue with multiple phenotype files (#20) Importance: High

Hi there,

I am trying to use multiple phenotypes and have been getting the error 'NoneType' object is not subscriptable. I have used space and tab delimited files with and without column names without success.

I tried running:

import numpy as np

from fastlmm.association import single_snp

pheno_both = "C:/Users/koapl/OneDrive/Desktop/data/double_pheno.txt"

bed_fn = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/Potri.001G385100.vcf.gz.bed"

results_df = single_snp(bed_fn, pheno_both, count_A1=False)

This is an example file: double_pheno.txthttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffastlmm%2FFaST-LMM%2Ffiles%2F6804150%2Fdouble_pheno.txt&data=04%7C01%7C%7C70cfb32f661c446eee9d08d945796906%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637617210017927645%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=PXrzk%2F%2FrGcCuL1PStjBFkrRj5MBTNxthh7tf85rNUcM%3D&reserved=0

Do you know what is causing this error and how I can fix it? My single phenotype files have been running without issue.

Thanks in advance, Koa

- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffastlmm%2FFaST-LMM%2Fissues%2F20&data=04%7C01%7C%7C70cfb32f661c446eee9d08d945796906%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637617210017937598%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=48Xx93YPR8wFuF5PHDEwnnxoawUi480fVD1NUANASNU%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABR65P7V2YCCKXSNSKYJCFDTXNK2PANCNFSM5AHT6DWQ&data=04%7C01%7C%7C70cfb32f661c446eee9d08d945796906%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637617210017937598%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rUTdPkEoQccjTQ4dXFAwziISSzUqaDtW7Ek9gLsxVrI%3D&reserved=0.

koa-planedin commented 3 years ago

Hi Carl,

thank you for the quick reply!

I am using python 3.8.5, fastlmm 0.5.9, pysnptools 0.5.2, and bed-reader 0.2.5. Unfortunately, the suggested code is still giving me a 'NoneType' object is not subscriptable error.

Best, Koa

koa-planedin commented 3 years ago

Hi Carl,

Just wanted to follow up as I've been trying more solutions with no success. I have tried putting my own data into SnpData() the way it is shown in the example, but still get the same error on every multiple phenotype variation.

pheno_file_1 = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/pheno_Potri.001G385100.txt"
pheno_file_2 = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/pheno_Potri.001G395300.txt"
pheno1 = Pheno(pheno_file_1).read()
pheno2 = Pheno(pheno_file_2).read()
pheno3 = SnpData(iid=pheno1.iid,
                 sid=["Potri.001G385100","Potri.001G395300"],
                 val= np.c_[pheno1.val,pheno2.val]
)
pheno4 = SnpData(iid=pheno1.iid,
                sid=["original","sqrt","square"],
                 val= np.c_[pheno1.val,pheno1.val**2,pheno1.val**3]
                )

Could there be a problem with the bed file? The bed file works with my single phenotype files, but I'm not sure what else could be causing the issue. I would attach an example bed file I am working with, but they are not supported on this platform.

Thanks in advance, Koa

CarlKCarlK commented 3 years ago

Koa,

[If you want, you can email me directly at carlk [at]msn.com]

That looks pretty good.

What error messages are you getting? Can you please print pheno1.shape pheno2.shape

From: koa-planedin @.> Sent: Wednesday, July 21, 2021 4:39 PM To: fastlmm/FaST-LMM @.> Cc: Carl Kadie @.>; Comment @.> Subject: Re: [fastlmm/FaST-LMM] Issue with multiple phenotype files (#20) Importance: High

Hi Carl,

Just wanted to follow up as I've been trying more solutions with no success. I have tried putting my own data into SnpData() the way it is shown in the example, but still get the same error on every multiple phenotype variation.

pheno_file_1 = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/pheno_Potri.001G385100.txt"

pheno_file_2 = "C:/Users/koapl/OneDrive/Desktop/data/leaf-files/pheno_Potri.001G395300.txt"

pheno1 = Pheno(pheno_file_1).read()

pheno2 = Pheno(pheno_file_2).read()

pheno3 = SnpData(iid=pheno1.iid,

             sid=["Potri.001G385100","Potri.001G395300"],

             val= np.c_[pheno1.val,pheno2.val]

)

pheno4 = SnpData(iid=pheno1.iid,

            sid=["original","sqrt","square"],

             val= np.c_[pheno1.val,pheno1.val**2,pheno1.val**3]

            )

Could there be a problem with the bed file? The bed file works with my single phenotype files, but I'm not sure what else could be causing the issue. I would attach an example bed file I am working with, but they are not supported on this platform.

Thanks in advance, Koa

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffastlmm%2FFaST-LMM%2Fissues%2F20%23issuecomment-884565303&data=04%7C01%7C%7Ce8c02119482a43579fe108d94ca0be04%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637625075532543803%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=7NqLKU0ZAqu8I%2BIF0Ygl4ikl4nBFmG95OYPFxgvYxxU%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABR65P2OGUE2DPLXRHQDCSDTY5LB5ANCNFSM5AHT6DWQ&data=04%7C01%7C%7Ce8c02119482a43579fe108d94ca0be04%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637625075532543803%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IpsEaAV4YFma6NMvqji6yamF7dCJQtTuPerPka1oyWU%3D&reserved=0.

koa-planedin commented 3 years ago

Hi Carl,

I sent you an email elaborating, please let me know if it didn't go through!

Best, Koa

CarlKCarlK commented 3 years ago

Koa,

I see it now. Thanks for the heads up. It should see future emails.

From: koa-planedin @.> Sent: Friday, July 23, 2021 10:43 AM To: fastlmm/FaST-LMM @.> Cc: Carl Kadie @.>; Comment @.> Subject: Re: [fastlmm/FaST-LMM] Issue with multiple phenotype files (#20) Importance: High

Hi Carl,

I sent you an email elaborating, please let me know if it didn't go through!

Best, Koa

- You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffastlmm%2FFaST-LMM%2Fissues%2F20%23issuecomment-885797312&data=04%7C01%7C%7C4a320045492d490732f208d94e014aa0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637626589712576955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=diQwfufOGp21ORPE3mgh7rND9e82JIV3iCuzLAlKjhk%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABR65PZPM34SYFS5YTXH3TTTZGSZVANCNFSM5AHT6DWQ&data=04%7C01%7C%7C4a320045492d490732f208d94e014aa0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637626589712576955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pRqPt4anXlAc8SUJyzQwHF%2B%2FyUJsL5DLXKQHbwym5ZA%3D&reserved=0.