DyogenIBENS / Agora

Algorithm For Gene Order Reconstruction in Ancestors
Other
70 stars 15 forks source link

how to use misc.compareGenomes.py? #3

Closed ShuaiNIEgithub closed 2 years ago

ShuaiNIEgithub commented 2 years ago

Hi, teams thanks for your works on Agora.

I think the script "misc.compareGenomes.py" looks great. However, I got an error while running it with the example data. Did I get the input file wrong? or anything?

Could you please give me some advice to using the script?

Thank you very much.

This is my code:

src/misc.compareGenomes.py \
example/data/genes/genes.M1.list.bz2 \
example/data/genes/genes.M2.list.bz2 \
example/results/ancGenes/all/ancGenes.A3.list.bz2 \
-mode=drawKaryotype \
-minChrSize=200 > M1M2_min200genes.ps

The Error:

--------------------------------------------------------------------------------
| Key                      | Values                                            |
--------------------------------------------------------------------------------
| studiedGenome            | example/data/genes/genes.M1.list.bz2              |
| referenceGenome          | example/data/genes/genes.M2.list.bz2              |
| orthologuesList          | example/results/ancGenes/all/ancGenes.A3.list.bz2 |
| includeGaps              | False                                             |
| includeScaffolds         | True                                              |
| includeRandoms           | False                                             |
| includeNones             | False                                             |
| reverse                  | False                                             |
| mode                     | drawKaryotype                                     |
| orthoslist:fullgenenames | False                                             |
| orthoschr:minHomology    | 90                                                |
| minChrSize               | 200                                               |
| matrix:scaleY            | False                                             |
| matrix:pointSize         | -1                                                |
| sortBySize               | False                                             |
| matrix:colorFile         |                                                   |
| matrix:defaultColor      | black                                             |
| matrix:penColor          | black                                             |
| karyo:landscape          | False                                             |
| ps:backgroundColor       |                                                   |
| karyo:roundedChr         | False                                             |
| karyo:resolution         | 1                                                 |
| karyo:showText           | True                                              |
| karyo:drawBorder         | False                                             |
| karyo:defaultColor       |                                                   |
| karyo:penColor           | black                                             |
--------------------------------------------------------------------------------
Loading genome of example/results/ancGenes/all/ancGenes.A3.list.bz2 ... (ancestral genes) OK
Loading genome of example/data/genes/genes.M1.list.bz2 ... (Ensembl) OK
Loading genome of example/data/genes/genes.M2.list.bz2 ... (Ensembl) OK
27 24
Traceback (most recent call last):
  File "src/misc.compareGenomes.py", line 264, in <module>
    eval(str(arguments["mode"]))()
  File "src/misc.compareGenomes.py", line 161, in drawKaryotype
    (lx,ly) = utils.myPsOutput.printPsHeader(arguments["karyo:landscape"])
  File "/home/nieshuai/bin/Agora-master/src/utils/myPsOutput.py", line 24, in printPsHeader
    initColor()
  File "/home/nieshuai/bin/Agora-master/src/utils/myPsOutput.py", line 54, in initColor
    location = [f for f in knownLocations if os.path.exists(f)][0]
IndexError: list index out of range
DyogenIBENS commented 2 years ago

Hi, thank you for using AGORA. it seems that the scripts can't access to /etc/X11/rgb.txt nor /opt/X11/share/X11/rgb.txt on your computer (defined on line 51 and 52 of src/utils/myPsOutput.py). Can you tell me on what os you're running the script?

thanks in advance, Alexandra

ShuaiNIEgithub commented 2 years ago

Hi, Alexandra

Thanks for your reply. My OS is: CentOS Linux release 8.1.1911 (Core). And you are right, the problem is indeed that src/utils/myPsOutput.py can't access to rgb.txt. The rgb.txt is located in /usr/share/X11 on my computer. When I add "/usr/share/X11/rgb.txt" to line 53 of "myPsOutput.py", misc.compareGenomes.py is run successfully!

But I encountered a new problem when converting ps to pdf: only the text "Chromosome ID", but no color filled graphics in the pdf file. Am I using the wrong code?

This is my code: (no bug report)

src/misc.compareGenomes.py \
example/data/genes/genes.M1.list.bz2 \
example/data/genes/genes.M2.list.bz2 \
example/results/ancGenes/all/ancGenes.A3.list.bz2 \
-mode=drawKaryotype \
-minChrSize=200 > M1M2_min200genes.ps
ps2pdf M1M2_min200genes.ps M1M2_min200genes.pdf

--------------------------------------------------------------------------------
| Key                      | Values                                            |
--------------------------------------------------------------------------------
| studiedGenome            | example/data/genes/genes.M1.list.bz2              |
| referenceGenome          | example/data/genes/genes.M2.list.bz2              |
| orthologuesList          | example/results/ancGenes/all/ancGenes.A3.list.bz2 |
| includeGaps              | False                                             |
| includeScaffolds         | True                                              |
| includeRandoms           | False                                             |
| includeNones             | False                                             |
| reverse                  | False                                             |
| mode                     | drawKaryotype                                     |
| orthoslist:fullgenenames | False                                             |
| orthoschr:minHomology    | 90                                                |
| minChrSize               | 200                                               |
| matrix:scaleY            | False                                             |
| matrix:pointSize         | -1                                                |
| sortBySize               | False                                             |
| matrix:colorFile         |                                                   |
| matrix:defaultColor      | black                                             |
| matrix:penColor          | black                                             |
| karyo:landscape          | False                                             |
| ps:backgroundColor       |                                                   |
| karyo:roundedChr         | False                                             |
| karyo:resolution         | 1                                                 |
| karyo:showText           | True                                              |
| karyo:drawBorder         | False                                             |
| karyo:defaultColor       |                                                   |
| karyo:penColor           | black                                             |
--------------------------------------------------------------------------------
Loading genome of example/results/ancGenes/all/ancGenes.A3.list.bz2 ... (ancestral genes) OK
Loading genome of example/data/genes/genes.M1.list.bz2 ... (Ensembl) OK
Loading genome of example/data/genes/genes.M2.list.bz2 ... (Ensembl) OK
27 24
Affichage ... OK

Looking forward to hearing from you. Best wishes, Shuai

ShuaiNIEgithub commented 2 years ago

The same problem occurs when I open the ps file "M1M2_min200genes.ps" in photoshop.

DyogenIBENS commented 2 years ago

Hi, the command line is correct, but at the present time, misc.compareGenomes.py uses chromosome number for the initialization of the color for the option drawKaryotype. I'm working on this bug fix, but mean while, if you replace the chromosome names (i.e Chr1) by only the chromosome number (i.e 1), in the genes files, it will work. I'll come back to you as soon as the bug is fixed. Sorry for the inconvenient. Best wishes, Alexandra

ShuaiNIEgithub commented 2 years ago

Dear Alexandra, it was a pleasure to work with you to refine this script, the process was very interesting. So please don't be sorry.

And you are right, I ran the command line successfully after replacing the chromosome names. I also tested it with my own data and it works fine!

Then, I think it would be helpful if the script could output another plot to illustrate what each coloured block represents. I guess we drew the chromosomes of M1, and the different coloured blocks correspond to different chromosomes of M2. But I am not sure which chromosome is represented by a certain coloured block. Maybe chr1 is red?

Looking forward to your better works, and thank you so much.

Bests, Shuai

DyogenIBENS commented 2 years ago

Dear Shuai, to have the color corresponding to M2, you can use the same script, but comparing the genome with... itself...

if you run: src/misc.compareGenomes.py genes.M2 genes.M2 tmp/ancGenes/all/ancGenes.M2.list.bz2 -mode=drawKaryotype > M2.ps

you should have the corresponding color. I take into account your remark and add it on the todo list.

Best, Alexandra

ShuaiNIEgithub commented 2 years ago

It worked successfully. It's really cleverly designed to compare itself to itself!

muffato commented 2 years ago

Dear Shuai,

I have pushed a fix on the bugfix/3 branch. src/misc.compareGenomes.py is now able to draw karyotypes regardless of how the chromosomes are named (the colour scale corresponds to the chromosomes by decreasing size). Could you give it a try ?

Regards, Matthieu

ShuaiNIEgithub commented 2 years ago

Dear Matthieu,

It worked out! Your team is the most efficient one I've ever seen, many thanks!

Bests, Shuai

muffato commented 2 years ago

You're most welcome. FYI, the bugfix is now on the master branch too.

Best regards, Matthieu