Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw Gene structure Map with gggenes

2025-03-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to use gggenes to draw a gene structure map, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Gggenes is an R package based on ggplot2, which can easily draw the gene structure map shown in the following figure.

1. Install the R package directly from the CRAN official source:

Install.packages ("gggenes")

Or download and install from github:

Devtools::install_github ("wilkox/gggenes")

two。 Prepare to enter data

The official examples are as follows:

> head (example_genes) molecule gene start end strand direction1 Genome5 genA 405113 407035 forward 12 Genome5 genB 407035 407916 forward 13 Genome5 genC 407927 408394 forward 14 Genome5 genD 408387 408737 reverse-15 Genome5 genE 408751 409830 forward 16 Genome5 genF 409836 410315 forward 1

The input data should contain 6 columns, which represent:

Species name, gene name, start position, end position, gene direction.

If you don't need to consider drawing the direction of the gene, you only need the first four columns of data: species name, gene name, start position, end position.

If you add the gene direction, you need to add the strand column, and the positive and negative chains are represented by "forward" and "reverse". The direction column in the sample data is redundant and will not be used.

two。 Draw a picture

Library (ggplot2) library (gggenes)

Ggplot (example_genes, aes (xmin = start, xmax = end, y = molecule, fill = gene) + geom_gene_arrow () + facet_wrap (~ molecule, scales = "free", ncol = 1) + scale_fill_brewer (palette = "Set3") + theme_genes ()

The figure is as follows:

As you can see, we use the familiar ggplot2 syntax, coupled with the geom_gene_arrow () function to achieve the mapping of gene structure.

Below, we add the direction, as well as the gene name, the code is as follows:

Ggplot (example_genes, aes (xmin = start, xmax = end, y = molecule, fill = gene, label = gene, forward = direction) + geom_gene_arrow () + facet_wrap (~ molecule, scales = "free", ncol = 1) + scale_fill_brewer (palette = "Set3") + theme_genes () + geom_gene_label (align = "left")

Label = gene, forward = direction specifies the gene name and direction

Geom_gene_label (align = "left") adds the gene name to the graph and aligns it to the left

3. Other uses

Gggenes can also show gene domain characteristics or alignment information as shown in the figure above, which can be achieved by using the geom_subgene_arrow () function. You need to use another data example_subgenes, as shown in the code below:

> head (example_subgenes) molecule gene start end strand subgene from to1 Genome5 genA 405113 407035 forward genA-1 405774 4065382 Genome5 genB 407035 407916 forward genB-1 407458 4078973 Genome5 genC 407927408394 forward genC-1 4079424081584 Genome5 genC 407927408394 forward genC-2 408186 4082095 Genome5 genC 407927408394 forward genC-3 408233 408257ggplot (example_genes, aes (xmin = start, xmax = end, y = molecule)) + facet_wrap (~ molecule, scales = "free") Ncol = 1) + geom_gene_arrow (fill = "white") + geom_subgene_arrow (data = example_subgenes, aes (xmin = start, xmax = end, y = molecule, fill = gene, xsubmin = from, xsubmax = to), color= "black", alpha=.7) + theme_genes () is how to draw the gene structure map with gggenes. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report