Closed genec1 closed 2 years ago
@genec1 - looking at this now, thanks for the report.
@genec1, The constructor's host argument is a bad idea - my bad idea, left over from a long time ago. The man page on the constructor illuminates this, partly:
@param host In practice, this is always "localhost"
The justification: igvR displays in your browser, and it is hard for me to imagine a case when "your browser" runs on anything but localhost. Do you have a use-case that suggests otherwise? I'd be glad to see that, and to see if I can support it.
Even with this historical relic cleaned up, I have not helped you with your problem. Let me make sure I understand what that is. The best way would be for you to include the code with which you construct your GenomicAlignmentsTrack object. Here are two examples from inst/unitTests/test_igvR.R
.
First, display an alignment already read into memory:
little.region <- GRanges(seqnames="21", ranges=IRanges(10400126, 10400326))
param <- ScanBamParam(which=little.region, what=scanBamWhat())
x <- readGAlignments(bamFile, use.names=TRUE, param=param)
track <- GenomicAlignmentTrack("bam demo", x, visibilityWindow=2000000, trackHeight=500) # 30000 default
displayTrack(igv, track)
Second, display an alignment hosted elsewhere:
url <- "https://1000genomes.s3.amazonaws.com/phase3/data/HG02450/alignment/HG02450.mapped.ILLUMINA.bwa.ACB.low_coverage.20120522.bam"
index <- "https://1000genomes.s3.amazonaws.com/phase3/data/HG02450/alignment/HG02450.mapped.ILLUMINA.bwa.ACB.low_coverage.20120522.bam.bai"
track <- RemoteAlignmentTrack("remote bam", url, index, visibilityWindow=100000)
displayTrack(igv, track)
How do you create your track object?
@genec1, The constructor's host argument is a bad idea - my bad idea, left over from a long time ago. The man page on the constructor illuminates this, partly:
@param host In practice, this is always "localhost"
The justification: igvR displays in your browser, and it is hard for me to imagine a case when "your browser" runs on anything but localhost. Do you have a use-case that suggests otherwise? I'd be glad to see that, and to see if I can support it.
My particular use case is I’m running the code on an instance on AWS, as my local machine can’t handle the amount of data I’m working with.
Even with this historical relic cleaned up, I have not helped you with your problem. Let me make sure I understand what that is. The best way would be for you to include the code with which you construct your GenomicAlignmentsTrack object. Here are two examples from
inst/unitTests/test_igvR.R
.How do you create your track object?
I’m working with local bam files read into GenomicAlignment objects very similar to your first example. I will share actual code when I’m back on my workstation.
Thanks
Bam track display code:
# libraries
library(igvR)
library(BSgenome.Hsapiens.UCSC.hg38)
# setup igv
igv <- igvR(quiet=TRUE)
setGenome(igv, "hg38")
showGenomicRegion(igv, "chr17:7,663,654-7,692,258")
loc <- getGenomicRegion(igv)
logGR <- with(loc, GRanges(seqnames=chrom, ranges = IRanges(start, end)))
param <- ScanBamParam(which=logGR, what = scanBamWhat())
# setup bam
# <define BAM_FILE_PATH and BAM_TRACK_NAME>
galign <- readGAlignments(BAM_FILE_PATH, use.names=TRUE, param=param)
track <- GenomicAlignmentTrack(BAM_TRACK_NAME, galign)
displayTrack(igv, track)
# bam url: http://localhost:15001?/tmp/Rtmpqy9pbo/fileae83dff0a45.bam
# bam track height: 50
# viewer message: Error accessing resource: http://localhost:15001?/tmp/Rtmpqy9pbo/fileae83dff0a45.bam.bai Status: 0
Thanks @genec1. Could you also give me the exact BAM_FILE_PATH so that, with proper substitutions, I can emulate it here?
On Jan 31, 2022, at 9:03 AM, genec1 @.***> wrote:
Bam track display code:
libraries
library(igvR) library(BSgenome.Hsapiens.UCSC.hg38)
setup igv
igv <- igvR(quiet=TRUE) setGenome(igv, "hg38") showGenomicRegion(igv, "chr17:7,663,654-7,692,258") loc <- getGenomicRegion(igv) logGR <- with(loc, GRanges(seqnames=chrom, ranges = IRanges(start, end))) param <- ScanBamParam(which=logGR, what = scanBamWhat())
setup bam
galign <- readGAlignments(BAM_FILE_PATH, use.names=TRUE, param=param) track <- GenomicAlignmentTrack(BAM_TRACK_NAME, galign) displayTrack(igv, track)
bam url: http://localhost:15001?/tmp/Rtmpqy9pbo/fileae83dff0a45.bam
bam track height: 50
viewer message: Error accessing resource: http://localhost:15001?/tmp/Rtmpqy9pbo/fileae83dff0a45.bam.bai Status: 0
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.
BAM_FILE_PATH is the full path to a local file on the AWS instance where I'm running R, so I don't think it will be of help to you.
@genec1 - you are right, of course. I will need to name a file on my local system since yours will be invisible to me.
Nevertheless, and though you may think I am being silly, please provide me with the exact full file path you use.
On Jan 31, 2022, at 11:29 AM, genec1 @.***> wrote:
BAM_FILE_PATH is the full path to a local file on the AWS instance where I'm running R, so I don't think it will be of help to you.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.
No problem. I'm working with multiple files, but here is one:
/home/rstudio/s3/HEK293T/SRR844_1.filtered.aligned.unique.bam
Hi @genec1. I am slow on the uptake here. Sorry. Let me ask a few more questions.
1) You built igvR on an aws instance. 2) You start igvR from an R session on that instance. 3a) Do you ask igvR to open a websocket connection, from aws, back to a browser running on your workstation, which is local - that is, you sit in front of it 3b) Or do you start up a web browser which runs on the aws instance, which displays (via X windows, for instance) which displays back to your workstation?
You explained that you use aws because the of the large amount of data that you are working with.
When I finally understand your setup, my response is likely to be this:
o igvR is really meant to be run only out of an R session on your local machine o when I have heavy processing to do, resulting in large genomic data files I want to explore, here is what I do: 1) set up a simple byte-range/CORS webserver on the compute server (your aws instance) 2) create and write your big data, indexed bam, vcf, cram etc files there 3) visualize them through the local igvR
It take a little effort to set up the byte-range/CORS webserver, but only a little. I could help with that.
On Jan 31, 2022, at 11:39 AM, genec1 @.***> wrote:
No problem. I'm working with multiple files, but here is one: /home/rstudio/s3/HEK293T/SRR844_1.filtered.aligned.unique.bam
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.
1 + 2 + 3a
Specifically, I am coding in a local web browser running RStudio, backed by rstudio-server on the AWS instance. When I initiate igvR in my R session, a new window opens in my local web browser showing IGV. This new window correctly shows the reference genome, but cannot show the programmatically loaded bam data since that is not on localhost relative to my browser session.
As a stopgap, I have been region-filtering the bams on AWS, sftp'ing them to my local machine, and opening them in a local IGV app. This is cumbersome for multiple bams with multiple regions. If you can point me to the byte-range/CORS server info, that would be appreciated!
@genec1 I have a presentation to give tomorrow, so today I can only give you quick & dirty instructions on creating a python flask webserver for serving up indexed genomic files, bam and vcf, for instance. I will polish these up by the end of the week and add them to this repo's README. I hope the following gets you going. Let me know:
serveStaticGenomeFiles.py
:
from flask import Flask
from flask_cors import CORS
app = Flask(__name__, static_url_path='/static')
CORS(app)
@app.route('/')
def serveStaticFiles():
return 'CORS and byte-range request flask webserver for igvR\n'
if name == "main": app.run(host='0.0.0.0', port='60050')
- adjust the port to something appropriate
- run the python script with your files in ```/static``` of whatever path you specify when you construct the ```app``
I run all of this out of Docker container, and will document that as well.
I hope this quick description is helpful. I will incorporate your judgement, and appropriate improvements, when I have a chance to do this later in the week.
This is very much appreciated! I do not have the time to try it at the moment, but will give it a go in a week or two.
@genec1 I think I have figured out a few changes needed to run igvR from a remote RStudio (or plain R) session. I will be testing in the next few days. I hope this will be useful to you.
@genec1 igvR 1.15.8 and BrowserViz 2.17.1 just passed all tests for me, running in a remote RStudio Server session. Give it a try?
@paul-shannon I can confirm that it works with the GitHub versions when using the host parameter and running on a remote host. Awesome!
Glad this worked out! Let me know if you have other suggestions.
On Mar 1, 2022, at 4:39 PM, genec1 @.***> wrote:
@paul-shannon I can confirm that it works with the GitHub versions when using the host parameter and running on a remote host. Awesome!
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.
The host parameter specified by the igvR constructor appears to be ignored and this is leading to errors displaying tracks:
Note that the
uri
slot and the displayTrack message both say "localhost" instead of the host value I specified. The actual viewer also displays an error:Error accessing resource: http://localhost:15003?/tmp/Rtmp0ZcCIP/filec49620e6c76a.bam.bai Status: 0
sessionInfo()
is:EDIT: I manually edited the contents of the
uri
slot, but am still getting the viewer error. The path in the URL "/tmp/Rtmp0ZcCIP/filec49620e6c76a.bam" is the correct file. When I uselsof
on the command line, I notice that rsession is still listening onlocalhost
instead of the ip, so I think that is still the issue.