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

load a specific type of feature from gff3tabix #974

Closed
Yating-L opened this Issue Feb 5, 2018 · 12 comments

Comments

Projects
None yet
4 participants
@Yating-L

Yating-L commented Feb 5, 2018

I can use the --type argument for flatfile-to-json.pl to only load mRNA/transcript from source gff3 file. Now I'd like to use gff3tabix instead. Are there any equivalent methods to load a specific type of features? Thank you!

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 5, 2018

@Yating-L You should just point to the gff3 tabix file. If you look at the in-memory GFF3Tabix adapter for volvox it should work. Keep in mind, there are still a few issues (#969), #780, #935.

Hope to have some fixes for those, soon. However, if its a limited range and you are using Canvas tracks (and are JBrowse only) it should work fairly well.

@Yating-L

This comment has been minimized.

Yating-L commented Feb 5, 2018

@nathandunn It works when "mRNA" is in column 3 of the GFF. But not work when "transcript" is in column 3. It looks like loading "mRNA" is the default setting for HTMLFeatures: load subfeatures. I might be wrong.

Where can I find "the in-memory GFF3Tabix adapter for volvox"? Thanks!

@cmdcolin

This comment has been minimized.

Contributor

cmdcolin commented Feb 5, 2018

You can set "transcriptType": "transcript" in your config to fix that particular issue of transcript instead of mRNA in column 3 (for canvasfeatures tracks)

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 5, 2018

@Yating-L

This comment has been minimized.

Yating-L commented Feb 5, 2018

@cmdcolin @nathandunn I think set "transcriptType": "transcript" only works for CanvasFeature. I need to use HTMLFeature for Apollo/JBrowse.

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 5, 2018

@Yating-L This is on my list of things to fix. I have a partial fix for HTMLFeatures here (though I'm going to abandon this PR): https://github.com/GMOD/Apollo/pull/1822/files#diff-09b50a85a7f9125fad0738f4dc234797R1031 probably when solving this issue #969.

I think #956 (Canvas GFF3Tabix histograms) might need to be integrated first (hopefully this week). Feel free to take a stab at the fix, though.

The other problem with HTMLFeatures was that if you include a gene in the GFF3 it ONLY shows the top-level by default. I try to incorporate that fix, as well, but I doubt it covers all types or is sufficiently configurable.

The code for both Tabix and HTMLFeatures is pretty readable. I hope to get them both out this month, but feel free to start fixing the HTMLFeatures code for tabix (I think they are small fixes relative to the PR).

@cmdcolin

This comment has been minimized.

Contributor

cmdcolin commented Feb 5, 2018

I see. I guess for HTMLFeatures, the fundamental problem is that HTMLFeatures doesn't display the individual transcripts when loaded at the gene level. Anything sort of aside from that like filtering on type for gff3tabix is sort of a workaround to that fundamental issue

I have looked into a fix for this fundamental problem and I think it could be done

For example here is an example

diff --git a/src/JBrowse/View/Track/HTMLFeatures.js b/src/JBrowse/View/Track/HTMLFeatures.js
index 5465c30..a2cb740 100644
--- a/src/JBrowse/View/Track/HTMLFeatures.js
+++ b/src/JBrowse/View/Track/HTMLFeatures.js
@@ -696,14 +696,36 @@ define( [
              */
             addFeatureToBlock: function( feature, uniqueId, block, scale, labelScale, descriptionScale,
                                          containerStart, containerEnd ) {
-                var featDiv = this.renderFeature( feature, uniqueId, block, scale, labelScale, descriptionScale,
-                    containerStart, containerEnd );
-                if( ! featDiv )
-                    return null;
+                var thisB = this;
+                if( feature.get('type') == 'gene') {
+                    var d = dojo.create('div');
+                    var feats = feature.get('subfeatures');
+                    if(!feats) {
+                        return null;
+                    }
+                    var featDivs = feats.map(function( feat ) {
+                        return thisB.renderFeature(feat, uniqueId + '_' + feat.get('id'), block, scale, labelScale, descriptionScale, containerStart, containerEnd);
+                    });
+                    featDivs.forEach(function( featDiv ) {
+                        d.appendChild( featDiv );
+                    });
+                    block.domNode.appendChild( d );
+                    if( this.config.style.centerChildrenVertically ) {
+                        featDivs.forEach(function( featDiv ) {
+                            thisB._centerChildrenVertically( featDiv );
+                        });
+                    }
+                    return d;
+                } else {
+                    var featDiv = this.renderFeature( feature, uniqueId, block, scale, labelScale, descriptionScale,
+                        containerStart, containerEnd );
+                    if( ! featDiv )
+                        return null;

-                block.domNode.appendChild( featDiv );
-                if( this.config.style.centerChildrenVertically )
-                    this._centerChildrenVertically( featDiv );
+                    block.domNode.appendChild( featDiv );
+                    if( this.config.style.centerChildrenVertically )
+                        this._centerChildrenVertically( featDiv );
+                }
                 return featDiv;
             },

This now allows you to load flatfile-to-json.pl on a GFF with --type gene and all individual transcripts can be displayed. Or, similarly, just use a gff3tabix with gene type features in it.

I'd be curious what @rbuels thinks about this type of approach

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 5, 2018

I think this would be good. The other issue was that when block sizes didn't line up (with HTMLFeatures) it would only render exons for one block or the other. The fix was to create alternate blocks so that there was no intersection of the block query and the transcripts. Again, doesn't affect the canvas, but it should be in GFF3Tabix Histogram PR (if not, I'll put it there).

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 20, 2018

@cmdcolin I merged this in (d19f4e4), which is similar to another fix I had in my client-side project branch (though sort of in tatters), but I can't remember what:

#974 (comment)

Its definitely better, but it seems to ignore Genes entirely. I think we still want them in the model, if possible, but we don't want to render them. It does something screwy to the introns, as well.

screen shot 2018-02-19 at 10 04 27 pm

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 20, 2018

Either way its a step in the right direction. My solution had them all stacked as you have shown here: #969 (comment)

so it definitely fixed that problem.

@nathandunn

This comment has been minimized.

Contributor

nathandunn commented Feb 20, 2018

@cmdcolin Of course, this might be due to a weird interaction with neat features. Granted, I had sort of gotten it working based on the Apollo code in branching where it was able to explicitly render the exon segments: https://github.com/nathandunn/Apollo/blob/2.1.0/client/apollo/js/View/Track/DraggableHTMLFeatures.js#L947

@rbuels rbuels added this to the 1.14.0 milestone Apr 7, 2018

@rbuels

This comment has been minimized.

Collaborator

rbuels commented Apr 7, 2018

in the dev branch now, which is going into the 1.14.0 release, there is support for a topLevelFeatures configuration variable.

so if you have a GFF3+Tabix file with gene models, that you have to use with HTMLFeatures, you can set topLevelFeatures = mRNA and the mRNAs in the gene models will be treated by HTMLFeatures as top-level, and it can render them using its normal two-level rendering.

Sound good? Feel free to reopen if this turns out not to work.

@rbuels rbuels closed this Apr 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment