Closed dongyiyi closed 3 years ago
Hi, I just tried the same and it worked for me (on Mac OS X). Can you tell me what's on line 81 of your test.rb
script? Did you try the command after downloading the three files using the links in the paragraph that starts with "To plot the heatmap, use the Ruby script..."?
Hi,
I downloaded the species_order.txt, samplestree.txt, samplesDmin.txt and samples__BBAA.txt. Then I copied the codes from your rsc folder
run the codes:
Traceback (most recent call last):
2: from test.rb:81:in
Besides, I tried to download the plot_d.rd from your link and save it to my PC. But I executed the plot_d.rd and got errors below: plot_d.rb:7: syntax error, unexpected '<' <!DOCTYPE html> plot_d.rb:8: syntax error, unexpected '<'
plot_d.rb:9: syntax error, unexpected '<' plot_d.rb:11: syntax error, unexpected '<'I see, I think you downloaded the scripts including the HTML in which they are embedded. Can you try to download in this way:
These files should not have the line numbers at the start of each line, as in the text that you pasted above.
I noticed that I downloaded the HTML file, and there is not a button to "Download file". So I copy the code from https://github.com/mmatschiner/tutorials/blob/master/analysis_of_introgression_with_snp_data/src/plot_d.rb
I got the error the first one that I mentioned: Traceback (most recent call last): 2: from test.rb:81:in ' 1: from test.rb:81:in open' test.rb:81:in `initialize': no implicit conversion of nil into String (TypeError)
Yes, there is not the line number in the script.
Can you try to download the files attached here in an archive and use these:
Archive.zip
Or at least compare them to your versions of the files? For me, it worked with the files in the archive.
It seems there's an issue with the command line arguments in your case, because the second argument is apparently not recognized (the heatmap_name_order_file_name). Can you make sure that you use this command:
ruby plot_d.rb samples__Dmin.txt species_order.txt 0.7 samples__Dmin.svg
Thanks, I downloaded the whole tutorials-master.zip, run the plot_d.rd; Or I downloaded the Archive.zip.
I got the same errors: Traceback (most recent call last): 2: from test.rb:81:in ' 1: from test.rb:81:in open' test.rb:81:in `initialize': no implicit conversion of nil into String (TypeError)
Are you sure you're running the script plot_d.rb
? The error message indicates that you are running a script named test.rb
.
Yes, I am runnig the plot_d.rd
Traceback (most recent call last):
2: from plot_d.rb:81:in <main>' 1: from plot_d.rb:81:in
open'
plot_d.rb:81:in `initialize': no implicit conversion of nil into String (TypeError)
Weird. Can you try to run the same command with the modfied version of the script that I attach here (sorry, it has to be compressed, otherwise GitHub won't allow uploading here): plot_d_edit.rb.zip So after uncompressing, run: ruby plot_d_edit.rb samples__Dmin.txt species_order.txt 0.7 samples__Dmin.svg The output of this may help us to understand what's going on.
Cool! I didn't get any errors, but no output file "samplesDmin.svg" in the folder. I can't find the result. ruby plot_d_edit.rb samplesDmin.txt species_order.txt 0.7 samplesDmin.svg asymmetry_table_file_name: samples__Dmin.txt heatmap_name_order_file_name: species_order.txt max_d_value: 0.7 plot_file_name: samplesDmin.svg
Thanks. I'm still not sure what's wrong, though. This script shows that "species_order.txt" is correctly recognized as parameter "heatmap_name_order_file_name". If you now delete lines 80-84 in the script plot_d_edit.rb
, this script should have the exact same content as the original script plot_d.rb
. Can you please do that and see if it runs then?
I deleted lines 80-84 in the Plot_d_edit.rb, got the same error:
Traceback (most recent call last):
2: from plot_d_edit.rb:82:in <main>' 1: from plot_d_edit.rb:82:in
open'
plot_d_edit.rb:82:in `initialize': no implicit conversion of nil into String (TypeError)
Where I can find the output files? There is not SVG file in the current folder.
Hi, Good news! I moved the "end" to the last line in the original plot_d.rd script, I got the result!
order_file = File.open(heatmapname_order_file_name)
order_lines = order_file.readlines
names_ordered = []
order_lines.each do |l|
names_ordered << l.strip unless l[0] == "#"
First,
end #about line 92 or 93, I deleted "end"
then,
I added the end ant the end of the script.
When I run the script plot_d.rd, I can get the result, but I just ruby plot_d.rd, I still get the same errors:
main.rb:84:in initialize': no implicit conversion of nil into String (TypeError) from main.rb:84:in
open'
from main.rb:84:in `
Did you get an SVG file? I'ld be surprised, the end
is there for a reason and it should not be moved. I guess you mean the end
in the line after names_ordered << l.strip unless l[0] == "#"
; thus, the one that is on line 85 in this version: https://github.com/mmatschiner/tutorials/blob/master/analysis_of_introgression_with_snp_data/src/plot_d.rb
Moving this end
can impossibly be the solution.
I'm not sure what you mean with this line:
When I run the script plot_d.rd, I can get the result, but I just ruby plot_d.rd, I still get the same errors
Is there something else that you do with the script? From your error message it now seems to be called main.rb
. Did you only rename?
Hi, I tried to run the plot_d.rd with your example dataset in ruby 2.7 in Win10 but I got the error: Traceback (most recent call last): 2: from test.rb:81:in
<main>' 1: from test.rb:81:in
open' test.rb:81:in `initialize': no implicit conversion of nil into String (TypeError) What should I do? I have no idea Thanks!