Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error creating dotplot #11

Open
Estherrr1997 opened this issue Nov 25, 2021 · 13 comments
Open

error creating dotplot #11

Estherrr1997 opened this issue Nov 25, 2021 · 13 comments

Comments

@Estherrr1997
Copy link

Hey there,

I am trying to create a dotplot of an alignment I made with minimap, I converted the minimap output (sam format) to a paf format and
tried running dotplotly on it to visualize the output.

This is the .slurm file I use to run dotplotly:

#!/bin/bash

#SBATCH --job-name=dotplot
#SBATCH --partition="cpu-short"
#SBATCH --ntasks=4
#SBATCH --time=03:00:00
#SBATCH --mem-per-cpu=4g

./pafCoordsDotPlotly.R -i /home/data/genome_alignments/paf_files/blue_shark_white_shark.paf
-o /home/data/genome_alignments/align_dotplots/outfile_bs_ws -s -t -m 500 -q 500000 -k 7 -l

this creates the following error:

PARAMETERS:
input (-i): /home/hsl_s1101570/data/genome_alignments/paf_files/blue_shark_white_shark.paf
output (-o): /home/hsl_s1101570/data/genome_alignments/align_dotplots/outfile_bs_ws
minimum query aggregate alignment length (-q): 5e+05
minimum alignment length (-m): 500
plot size (-p): 15
show horizontal lines (-l): TRUE
number of reference chromosomes to keep (-k): 7
show % identity (-s): TRUE
show % identity for on-target alignments only (-t): TRUE
produce interactive plot (-x): TRUE
reference IDs to keep (-r):

Number of alignments: 139943
Number of query sequences: 567

After filtering... Number of alignments: 6919
After filtering... Number of query sequences: 6

Warning: Ignoring unknown aesthetics: text
Error in .External2(C_X11, paste0("png::", filename), g$width, g$height, :
unable to start device PNG
Calls: ggsave -> dev ->
No traceback available
Error in htmlwidgets::saveWidget(as.widget(gply), file = paste0(opt$output_filename, :
Saving a widget with selfcontained = TRUE requires pandoc. For details see:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
3: grDevices::png(..., res = dpi, units = "in")
2: dev(filename = filename, width = dim[1], height = dim[2], ...)
1: ggsave(filename = paste0(opt$output_filename, ".png"), width = opt$plot_size,
height = opt$plot_size, units = "in", dpi = 300, limitsize = F)

Do you know how I can fix this?

Kind regards,
Esther

@mvolar
Copy link

mvolar commented Jan 4, 2022

The easiest solution is to get everything running locally, since this is a server error.

Most servers don't have R png support for graphics rendering (the X11 servers are really fussy, at least in my experience) or even if they do it is a pain to get it all to work properly.

You can also go into the code and make the program save a .Robject containing the graph and then load that .Robject into your local Rstudio installation in order to plot the graph.

@Estherrr1997
Copy link
Author

Ah okay thanks, I do still get the same error when running dotPlotly locally.
How can I save an Robject containing the graph? Guess that will be the solution for me.
Can you help me with that?

@mvolar
Copy link

mvolar commented Apr 1, 2022

Were you running it on Linux/MacOS or Windows?

If I had the same problem I would put

saveRDS(aligments, file = "alignments.rds")

in the source code for dot plot (on line 193 in pafCoordDotPlotly) in order to save the alignment file/table. Then you copy the plot making part of the file into your own script on your own PC, above that you put:

opt$on_target <- TRUE
opt$h_lines = FALSE
opt$similarity = FALSE

alignemnts <- readRDS("alignments.rds")

#plotting part of the script

If that doesn't work, you need to check whether or not ggplot2 works on your PC at all, maybe some reinstalling of packages will be needed.

@Estherrr1997
Copy link
Author

Thank you very much for your help! I changed the pafCoordsDotPlotly.R file and I think I successfully created a dotplot, although I keep getting an error message. Does this error message mean that the output still isn't right or is this a normal output plot?

The error message:
admin_bi@GSYMK2:/media/admin_bi/DATA/Files_Esther/dotPlotly$ ./pafCoordsDotPlotly.R -i /media/admin_bi/DATA/Files_Esther/paf_files/blue_shark_white_shark.paf -o out -s -t -m 500 -q 500000 -k 7 -l
PARAMETERS:
input (-i): /media/admin_bi/DATA/Files_Esther/paf_files/blue_shark_white_shark.paf
output (-o): out
minimum query aggregate alignment length (-q): 5e+05
minimum alignment length (-m): 500
plot size (-p): 15
show horizontal lines (-l): TRUE
number of reference chromosomes to keep (-k): 7
show % identity (-s): TRUE
show % identity for on-target alignments only (-t): TRUE
produce interactive plot (-x): TRUE
reference IDs to keep (-r):

Number of alignments: 139943
Number of query sequences: 567

After filtering... Number of alignments: 6919
After filtering... Number of query sequences: 6

Error in htmlwidgets::saveWidget(as.widget(gply), file = paste0(opt$output_filename, :
Saving a widget with selfcontained = TRUE requires pandoc. For details see:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
No traceback available
admin_bi@GSYMK2:/media/

And a screenshot of the plot (out.html):
Screenshot 2022-04-11 at 12-58-02 Screenshot

@mvolar
Copy link

mvolar commented Apr 11, 2022

This is the output, the html widget requires PANDOC which is a package meant for writing all types of documents, but you are most probably interested only in the .png/.svg output. If you want you can install the package and everything should work fine.

@Estherrr1997
Copy link
Author

Thank you so much! it runs with no errors now :)
Really appreciate your help!

@Estherrr1997
Copy link
Author

Okay one last thing: Is it possible that, due to the changes in the pafCoordsDotPlotly.R file, the output doesn't change after creating one dotplot? For six different shark assemblies (and the test data) I ran Dotplotly, but every output contains the exact same dotplot (the same one as the screenshot I attached to my last comment).

@mvolar
Copy link

mvolar commented Apr 13, 2022

The output should always be overwritten, I myself have lost couple of long drawing graphs in such manner, because of recklessness... Are you running the graphing plot within R/Rstudio?

@Estherrr1997
Copy link
Author

I am running it on the command line like this:

admin_bi@GSYMK2:/media/admin_bi/DATA/Files_Esther/dotPlotly$ ./pafCoordsDotPlotly.R -i /media/admin_bi/DATA/Files_Esther/paf_files/blue_shark_white_shark.paf -o blue_shark_white_shark -s -t -m 500 -q 500000 -k 7 -l

@mvolar
Copy link

mvolar commented Apr 13, 2022

Since it writes the outputfile_name from the output file name

73 opt$output_filename = unlist(strsplit(opt$output_filename, "/"))[length(unlist(strsplit(opt$output_filename, "/")))]

it should always respond to changes, have you tried different input/output filenames?

@Estherrr1997
Copy link
Author

Yes I have, for the different sharks I use different names, but I still get the same plots

@mvolar
Copy link

mvolar commented Apr 13, 2022

Then the error has to be in the .paf files you created using minimap2, since each time you run the script it reads the dana in the .paf files and cannot possibly draw same graph from different data, and the filenames are always generated anew.

@Estherrr1997
Copy link
Author

Okay thanks I will have a look at the data. Thank you for helping me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants