Syntax Error in both PrediXcan.py and MetaXcan.py

262 views
Skip to first unread message

Varoona Bizaoui

unread,
Jun 2, 2016, 7:50:35 PM6/2/16
to PrediXcan/MetaXcan

Hi,

My name is Varoona, I am a medical student specialized in medical genetics, and currently working at UCSF.

I have been recently starting to familiarize with the tools PrediXcan and MetaXcan, which I really hope I will be able to use soon, but I wonder why I keep on receiving this type of error :

for MetaXcan :

Traceback (most recent call last):
  File "/home/bizaouiv/bin/MetaXcan/software/MetaXcan.py", line 9, in <module>
    import M03_betas
  File "/home/bizaouiv/bin/MetaXcan/software/M03_betas.py", line 9, in <module>
    import metax.WeightDBUtilities as WeightDBUtilities
  File "/home/bizaouiv/bin/MetaXcan/software/metax/WeightDBUtilities.py", line 86
    extra = {e.gene:e for e in extra}
                        ^
SyntaxError: invalid syntax

for PrediXcan :

  File "/home/bizaouiv/bin/PrediXcanExample/PrediXcan.py", line 99
    self.gene_index = { gene:k for (k, gene) in enumerate(self.gene_list) }
                                 ^
SyntaxError: invalid syntax

I might have been doing something improperly.
I thought it might have something to do with the "sets" lately introduced in Python?
I just updated my Python version (2.7.11), and still have the same issue.

I would really appreciate if you had some idea or suggestions to help me with that.

Thank you very much,

Varoona

Alvaro Barbeira

unread,
Jun 3, 2016, 9:41:01 AM6/3/16
to Varoona Bizaoui, PrediXcan/MetaXcan
Hi Varoona,

I would need some additional information to track the cause, since that issue is not happening on my end, and I am using that syntax (dictionary comprehension) extensively.

- Is you python a standard precompiled distribution? Is it Conda or Pyenv-managed?
- What commands did you use to install/upgrade python?
- What is you platform? Linux, Mac OsX, Windows?
- When running Metaxcan, does it output a software version to the console?

Best,

Alvaro


--
You received this message because you are subscribed to the Google Groups "PrediXcan/MetaXcan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to predixcanmetax...@googlegroups.com.
To post to this group, send email to predixca...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/predixcanmetaxcan/a572812b-bdd3-44f7-aadd-b06acb0f73fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Chau

unread,
Dec 29, 2016, 11:32:38 PM12/29/16
to PrediXcan/MetaXcan, varo...@gmail.com
Dear Alvaro,

I am also experiencing syntax error on MetaXcan. I get the following error:

$ ./MetaXcan.py \
> --beta_folder intermediate/beta \
> --weight_db_path data/DGN-WB_0.5.db \
> --covariance data/covariance.DGN-WB_0.5.txt.gz \
> --gwas_folder data/GWAS \
> --gwas_file_pattern ".*gz" \
> --compressed \
> --beta_column BETA \
> --pvalue_column P \
> --output_file results/test.csv
  File "./MetaXcan.py", line 171
    except Exceptions.ReportableException, e:
                                                                 ^
SyntaxError: invalid syntax


I am using Python2.7.11 installed from Anaconda2, and am on a server with Ubuntu 16.04.
I have tried re-installing MetaXcan, but no luck

Thanks very much for your help in advance!
Cheers,

Carlos

Carlos Chau

unread,
Dec 29, 2016, 11:55:14 PM12/29/16
to PrediXcan/MetaXcan, varo...@gmail.com
Dear Alvaro,

I write to inform that I've pinned down where the culprit is - it's Anaconda3

I have both Anaconda3 and Anaconda2 installed, and I've  'alias python python2.7' in my .bash_profile to ensure MetaXcan uses python2.
Removing the "PATH='.../anaconda3/bin:$PATH" line added by Anaconda3 from my .bash_profile got MetaXcan working again.

I still don't understand why, but at least I can use it now. Thanks.

Carlos

Alvaro Barbeira

unread,
Dec 30, 2016, 9:04:27 AM12/30/16
to Carlos Chau, PrediXcan/MetaXcan, Varoona Bizaoui
Dear Carlos,

It is odd. I have used both Anaconda 3 and 2 with no problems... Maybe the anaconda 3 you were using had an older version of python, and it appeared earlier in the path than your Anaconda 2?

Best,

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to predixcanmetaxcan+unsubscribe@googlegroups.com.
To post to this group, send email to predixcanmetaxcan@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/predixcanmetaxcan/d1825440-7c42-410e-91d6-491419e9fe79%40googlegroups.com.

Carlos Chau

unread,
Jan 2, 2017, 11:34:01 PM1/2/17
to PrediXcan/MetaXcan, carlos....@gmail.com, varo...@gmail.com
Dear Alvaro,

Thank you very much for your reply! How very quick!

Hmm.. I have Anaconda3 4.0.0, and here's how my ./bash_profile looks like (Anaconda2 path is above Anaconda3's)

# added by Anaconda2 4.0.0 installer
export PATH="/exeh/exe3/ccarlos/bin/anaconda2/bin:$PATH"
# added by Anaconda3 4.0.0 installer
export PATH="/exeh/exe3/ccarlos/bin/anaconda3/bin:$PATH" 

Commenting out the last line gets MetaXcan to run without the below error.

  File "./MetaXcan.py", line 171
    except Exceptions.ReportableException, e:
                                                                 ^
SyntaxError: invalid syntax



I am quite happy to leave this as is since I can get MetaXcan running again.

Thank you very much for your quick help and support!


Carlos



farnush farhadi

unread,
Feb 23, 2017, 3:48:02 PM2/23/17
to PrediXcan/MetaXcan
Dear Alvaro, 

I am Farnush Farhadi, a graduate student in Bioinformatic and I am trying to use MetaXcan for my Transcriptomic model. 

I could run MetaXcan.py with sample data only once before. However, I got same syntax error whenever I tried after that: 

Command line I use to run MetaXcan: 
./MetaXcan.py --model_db_path data/data/DGN-WB_0.5.db --covariance data/data/covariance.DGN-WB_0.5.txt.gz --gwas_folder data/data/GWAS/ --gwas_file_pattern ".*gz" --beta_column BETA --pvalue_column P --output_file results/test2.csv

Error I get:
  File "./MetaXcan.py", line 96
    except Exceptions.ReportableException, e:
                                         ^
SyntaxError: invalid syntax

I use Conda. I downloaded Python from python.org. Then I installed packages by following command lines: 

sudo easy_install pip
pip install -U pip setuptools 
sudo pip install numpy 
sudo pip install pandas
sudo pip install scipy

I work with OSx platform. And I get no software version as the output of MetaXcan.py. It only gives me an error. 


I appreciate it if you could help. 

Cheers,
Farnush 

Alvaro Barbeira

unread,
Feb 23, 2017, 4:29:06 PM2/23/17
to farnush farhadi, PrediXcan/MetaXcan
Dear Farnush,

That error happens when python 3 is used. MetaXcan works only on python 2.7 for the moment (although we plan on supporting python 3 soon-ish).
So, I am guessing that you installed Conda with python 3. May I ask you to check by running python --version? If python on your environment is indeed python 3, then I advice to install a python 2 environment. Please let me know if this is not the case.

Best,

Alvaro

--
You received this message because you are subscribed to the Google Groups "PrediXcan/MetaXcan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to predixcanmetaxcan+unsubscribe@googlegroups.com.
To post to this group, send email to predixcanmetaxcan@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/predixcanmetaxcan/dc67c78d-075a-41b2-9fa8-4541724570be%40googlegroups.com.

farnush farhadi

unread,
Feb 23, 2017, 4:34:42 PM2/23/17
to Alvaro Barbeira, PrediXcan/MetaXcan
Dear Alvaro, 

Thank you for the very quick response. 

I restarted my computer as the last solution I know! and it worked afterwards! 

If I get into trouble again, I change my python version. Thank you.

Cheers,
Farnush 
--
Farnush Farhadi, M.Sc.
Dr. Sara Mostafavi’s Lab
Centre for Molecular Medicine and Therapeutics (CMMT)
University of British Columbia | Child & Family Research Institute
980 West 28th Avenue, Room 3109 | V5Z 4H4, Vancouver, BC, Canada
"Logic will get you from A to B. Imagination will take you everywhere" Albert Einstein

Natassja Brien

unread,
Apr 1, 2019, 11:24:04 AM4/1/19
to PrediXcan/MetaXcan
Hi there, 

I am an undergraduate student doing my honours project using PrediXcan. I am getting the same error as above, namely: 

  File "/home/nbrien/Tools/predixcan/PrediXcan.py", line 100

    self.gene_index = { gene:k for (k, gene) in enumerate(self.gene_list) }

                                 ^

SyntaxError: invalid syntax


I do not use Conda or another environment manager. I am trying to run PrediXcan in the MobaXterm shell on a computer that runs Windows. MobaXterm has Python pre-installed on the system - the version is 2.6.6. 

Please let me know if you think you can help.

Natassja Brien
To unsubscribe from this group and stop receiving emails from it, send an email to predixca...@googlegroups.com.

Alvaro Barbeira

unread,
Apr 1, 2019, 11:40:42 AM4/1/19
to Natassja Brien, PrediXcan/MetaXcan
Hi Natassja,

Python 2.6 is not supported; at least python 2.7 is required.

That said, I'm not aware of PrediXcan running on windows. If you plan on staying on windows, Conda is likely to be the best path as it can install both requirements of python and R. I understand Conda can coexist side by side with MobaXterm; or even be installed within it.

I strongly recommend switching to a UNIX-based OS such as Linux or Mac OS.

Best,

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to predixcanmetax...@googlegroups.com.

To post to this group, send email to predixca...@googlegroups.com.

Natassja Brien

unread,
Apr 2, 2019, 10:32:29 AM4/2/19
to PrediXcan/MetaXcan
Hi Alvaro, 

Thank you very much for your prompt reply. I will try your suggestions ASAP. 

Natassja

On Monday, 1 April 2019 10:40:42 UTC-5, Alvaro Barbeira wrote:
Hi Natassja,

Python 2.6 is not supported; at least python 2.7 is required.

That said, I'm not aware of PrediXcan running on windows. If you plan on staying on windows, Conda is likely to be the best path as it can install both requirements of python and R. I understand Conda can coexist side by side with MobaXterm; or even be installed within it.

I strongly recommend switching to a UNIX-based OS such as Linux or Mac OS.

Best,

Alvaro

Natassja Brien

unread,
Apr 4, 2019, 4:56:26 PM4/4/19
to PrediXcan/MetaXcan
Hi Alvaro, 

I have figured out the issue! I was using Moba to connect to WestGrid/Grex, and I needed certain commands to update python in Grex specifically. 

Thanks again. 

Natassja


On Monday, 1 April 2019 10:40:42 UTC-5, Alvaro Barbeira wrote:
Hi Natassja,

Python 2.6 is not supported; at least python 2.7 is required.

That said, I'm not aware of PrediXcan running on windows. If you plan on staying on windows, Conda is likely to be the best path as it can install both requirements of python and R. I understand Conda can coexist side by side with MobaXterm; or even be installed within it.

I strongly recommend switching to a UNIX-based OS such as Linux or Mac OS.

Best,

Alvaro

Alvaro Barbeira

unread,
Apr 4, 2019, 5:22:09 PM4/4/19
to Natassja Brien, PrediXcan/MetaXcan
Hi Nastassja,

Glad to hear.

As a passing comment: If Westgrid is a cluster, I'm surprised you would have to update python. I would expect different versions of python to be installed and available using commands like module load python/2.7.13.

Best,

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to predixcanmetax...@googlegroups.com.

To post to this group, send email to predixca...@googlegroups.com.

Alvaro Barbeira

unread,
Apr 5, 2019, 3:12:56 PM4/5/19
to Natassja Brien, PrediXcan/MetaXcan
Hi Natassja,

The samples file contains string IDs for the genotyped individuals. It is a headerless plain text file with two columns: family id of individual, and within-family id of the individual. If you only have individuals' ids, you can set the family id to the individual id.

Here is an example:

HG00096 HG00096
HG00097 HG00097
HG00099 HG00099
HG00100 HG00100
HG00101 HG00101
HG00102 HG00102
...

There can be additional columns but they will be ignored. Best,

Alvaro

On Fri, Apr 5, 2019 at 1:50 PM Natassja Brien <natassj...@gmail.com> wrote:
Hi Alvaro, 

Yes, you are correct! I suppose using "update" to describe what I had done wasn't very precise of me. 

If I may ask another question - I'm unsure about the samples.txt file. What should it look like? What is its purpose? I can't seem to find any information in the readme, apart from that I need to have one. 

Thank you!

Natassja

Natassja Brien

unread,
Apr 5, 2019, 3:56:56 PM4/5/19
to Alvaro Barbeira, PrediXcan/MetaXcan
Thank you very much! 
Reply all
Reply to author
Forward
0 new messages