Save plot on google cloud

Hi,
Do you have any examples - recommendations of a way to save a hail plot (manhattan plot) and write it to the google cloud bucket.
I can’t save directly to the google bucket. I get file not found errors. All I managed to do successfully is to write on the hail cluster master node but it is not ideal. I have to at the moment ssh to the hail-master node and then I ‘gsutil cp’ my html images to my google bucket. I am sure there is a much better way of doing this…

My code below for saving the plots for 35 covariates:

for i in range (0,36):
        print(f"Plotting {i}:{covariates[i]}")
        p = hl.plot.manhattan(gwas.p_value[i], title=f"Interval WGS GWAS Manhattan Plot: {covariates[i]}")
        output_file(f"wgs-manhattan-{covariates[i]}.html")
        save (p )

        p = hl.plot.qq(gwas.p_value[i], title=f"Interval WGS GWAS QQ Plot: {covariates[i]}" )
        #output_file(f"{BUCKET}/output-tables/wgs-qq-{covariates[i]}.html")
        output_file(f"wgs-qq-{covariates[i]}.html")
        save(p)

Thank you again,
Pavlos

It’s possible to do this programmatically with hail:

hl.hadoop_copy(local_file_html, 'gs://bucket/...')

https://hail.is/docs/0.2/utils/index.html#hail.utils.hadoop_copy

That’s perfect, thank you @tpoterba! :slight_smile:

If running from a jupyter notebook, you can also run shell commands inline using the ! magic:

! gsutil cp local_file_html gs:/...
1 Like

Hi @tpoterba. I am running hail on an hpc system. I would like to save hail plot in my directory locally. I tried looking for a save function in hail.plot but I can’t find it.
I am not running from jupyternotebook. I have an already prepared .py script which I run .

Hail plots use bokeh. Pavlos above is using the output_file and save functions imported from bokeh as in this post: https://stackoverflow.com/questions/31562898/bokeh-save-plot-as-html-but-dont-show-it