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

Fix ROI deletion feature #1880

Merged
merged 3 commits into from
Sep 4, 2024
Merged

Conversation

milandomazet
Copy link
Contributor

@milandomazet milandomazet commented Sep 2, 2024

Hello, this PR fixes a bug related to deletion of (user defined) ROIs. As we've moved roiSet to the menuItems method of ROIMenu we can now directly delete the ROI in question as there was a bug in finding the exact ROI (and its set) a user selected.

As can be seen in the video when a user defines a ROI over a ROI provided through config and then tries to delete it, the ROI provided through config gets deleted instead of the user defined one. In addition the ROI table was not being updated accordingly when a ROI is deleted.

Screen.Recording.2024-09-02.at.20.21.21.mov

const features = await set.getFeatures(chr, start, end)

for (let feature of features) {
if (feature.chr === chr && feature.start >= start && feature.end <= end) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line was causing the issue as it was not an exact match for start and end but we don't need this method now.

@milandomazet
Copy link
Contributor Author

FYI @turner

@jrobinso jrobinso requested a review from turner September 3, 2024 02:07
@turner turner removed their request for review September 3, 2024 16:35
@turner
Copy link
Contributor

turner commented Sep 3, 2024

@milandomazet can you clarify what you mean by " when a user defines a ROI over a ROI provided through config "? What do you mean by over here?

@milandomazet
Copy link
Contributor Author

@turner as you can see in the video basically the user defined region contains the previously provided region. For example region provided through config is chr1:100-150 and user defines a new region manually that is chr1:50-200

@turner
Copy link
Contributor

turner commented Sep 3, 2024

@milandomazet I did a test with your igvjs code in igv-web app. I pre-configured the app with a single ROI:

{
	"version": "3.0.4",
	"showSampleNames": false,
	"reference": {
		"id": "hg19",
		"name": "Human (GRCh37/hg19)",
		"fastaURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta",
		"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta.fai",
		"cytobandURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/cytoBand.txt.gz",
		"aliasURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chromAlias.txt",
		"twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.2bit",
		"chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chrom.sizes",
		"chromosomeOrder": "chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19,chr20,chr21,chr22,chrX,chrY"
	},
	"locus": "chr1:67,640,673-67,699,067",
	"roi": [
		{
			"name": "ROI set 2",
			"color": "rgba(3,52,249,0.25)",
			"features": [
				{
					"chr": "chr1",
					"start": 67670000,
					"end": 67671080,
					"name": "Set 2 feature 1"
				}
			],
			"isVisible": true
		}
	],
	"tracks": [
		{
			"type": "sequence",
			"order": -9007199254740991
		},
		{
			"name": "Refseq Genes",
			"format": "refgene",
			"id": "hg19_genes",
			"url": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/ncbiRefSeq.txt.gz",
			"indexed": false,
			"order": 1000000,
			"infoURL": "https://www.ncbi.nlm.nih.gov/gene/?term=$$",
			"type": "annotation",
			"height": 70
		}
	]
}

screenshot:
Screenshot 2024-09-03 at 2 43 30 PM

I then created a user-defined ROI:
Screenshot 2024-09-03 at 2 46 16 PM

I then deleted the user-defined ROI. It is correctly deleted and is nolonger visible in the table or in the browser. When I saved the session The user-generated ROI is present in the session file with an empty feature list:

{
	"version": "3.0.4",
	"showSampleNames": false,
	"reference": {
		"id": "hg19",
		"name": "Human (GRCh37/hg19)",
		"fastaURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta",
		"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/genomes/seq/hg19/hg19.fasta.fai",
		"cytobandURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/cytoBand.txt.gz",
		"aliasURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chromAlias.txt",
		"twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.2bit",
		"chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chrom.sizes",
		"chromosomeOrder": "chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19,chr20,chr21,chr22,chrX,chrY"
	},
	"locus": "chr1:67,666,220-67,673,519",
	"roi": [
		{
			"name": "ROI set 2",
			"color": "rgba(3,52,249,0.25)",
			"features": [
				{
					"chr": "chr1",
					"start": 67670000,
					"end": 67671080,
					"name": "Set 2 feature 1"
				}
			],
			"isVisible": true
		},
		{
			"name": "user defined",
			"color": "rgba(136,135,135,0.125)",
			"features": [],
			"isUserDefined": true,
			"isVisible": true
		}
	],
	"tracks": [
		{
			"type": "sequence",
			"order": -9007199254740991
		},
		{
			"name": "Refseq Genes",
			"format": "refgene",
			"id": "hg19_genes",
			"url": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/database/ncbiRefSeq.txt.gz",
			"indexed": false,
			"order": 1000000,
			"infoURL": "https://www.ncbi.nlm.nih.gov/gene/?term=$$",
			"type": "annotation",
			"height": 70
		}
	]
}

@milandomazet
Copy link
Contributor Author

@turner thanks for the feedback! To be honest I've never used session saving so I was not even checking this. Great point not just for this PR but for any future things I might do on IGV.js :)

Let me know if you see any issues with this approach.

@jrobinso jrobinso merged commit 87b3652 into igvteam:master Sep 4, 2024
1 check failed
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

Successfully merging this pull request may close these issues.

3 participants