From peaks to genes
Overview
question Questionsobjectives Objectives
How to use Galaxy?
How to get from peak regions to a list of gene names?
Familiarize yourself with the basics of Galaxy
Learn how to obtain data from external sources
Learn how to run tools
Learn how histories work
Learn how to create a workflow
Learn how to share your work
time Time estimation: 3 hours
level Level: Introductory level level level
Supporting Materials
last_modification Last modification: Jul 27, 2020
Introduction
We stumbled upon a paper (Li et al. 2012) called “The histone acetyltransferase MOF is a key regulator of the embryonic stem cell core transcriptional network”. The paper contains the analysis of possible target genes of an interesting protein called Mof. The targets were obtained by ChIP-seq in mice and the raw data is available through GEO. However, the list of genes is neither in the supplement of the paper, nor part of the GEO submission. The closest thing we could find is a file in GEO containing a list of the regions where the signal is significantly enriched (so called peaks):
1 | 3660676 | 3661050 | 375 | 210 | 62.0876250438913 | -2.00329386666667 |
1 | 3661326 | 3661500 | 175 | 102 | 28.2950833625942 | -0.695557142857143 |
1 | 3661976 | 3662325 | 350 | 275 | 48.3062708406486 | -1.29391285714286 |
1 | 3984926 | 3985075 | 150 | 93 | 34.1879823073944 | -0.816992 |
1 | 4424801 | 4424900 | 100 | 70 | 26.8023246007435 | -0.66282 |
Table 1 Subsample of the available file
The goal of this exercise is to turn this list of genomic regions into a list of possible target genes.
comment Note: results may vary
Your results may be slightly different from the ones presented in this tutorial due to differing versions of tools, reference data, external databases, or because of stochastic processes in the algorithms.
Agenda
In this tutorial, we will deal with:
Pretreatments
hands_on Hands-on: Open Galaxy
- Browse to a Galaxy instance: the one recommended by your instructor or one in the list Galaxy instance on the head of this page
Log in or register (top panel)
The Galaxy interface consist of three main parts. The available tools are listed on the left, your analysis history is recorded on the right, and the central panel will show the tools and datasets.

Let’s start with a fresh history.
hands_on Hands-on: Create history
Make sure you have an empty analysis history.
tip Tip: Creating a new history
Rename your history to make it easy to recognize
tip Rename a history
Data upload
hands_on Hands-on: Data upload
- Download the list of peak regions (the file
GSE37268_mof3.out.hpeak.txt.gz
) from GEO to your computerClick on the upload button in the upper left ot the interface
- Press Choose local file and search for your file on your computer
- Select
interval
as Type- Press Start
- Press Close
Wait for the upload to finish. Galaxy will automatically unpack the file.
After this you will see your first history item in Galaxy’s right pane. It will go through the gray (preparing/queued) and yellow (running) states to become green (success):
Directly uploading files is not the only way to get data into Galaxy
tip Tip: Importing data via links
tip Tip: Importing data to Galaxy
comment Interval file format
Interval format is a Galaxy format for representing genomic intervals. It is tab-separated, but has the added requirement that three of the columns must be:
- chromosome ID
- start position (0-based)
- end position (end-exclusive)
An optional strand column can also be specified, and an initial header row can be used to label the columns, which do not have to be in any special order. Unlike BED format (see below) arbitrary additional columns can also be present.
You can find more information about formats that can be used in Galaxy at the Galaxy Data Formats page.
hands_on Hands-on: Inspect and edit attributes of a file
Click on the file in the history panel
Some meta-information (e.g. format, reference database) about the file and the header of the file are then displayed, along with the number of lines in the file (48,647):
Click on the galaxy-eye (eye) icon (View data) in your dataset in the history
The content of the file is displayed in the central panel
Click on the galaxy-pencil (pencil) icon (Edit attributes) in your dataset in the history
A form to edit dataset attributes is displayed in the central panel
- Search for
mm9
in Database/Build attribute and selectMouse July 2007 (NCBI37/mm9)
(the paper tells us the peaks are frommm9
)- Click on Save on the top
- Add a tag called
#peaks
to the dataset to make it easier to track in the historytip Tip: Adding a tag
The dataset should now look like below in the history
In order to find the related genes to these peak regions, we also need a list of genes in mice, which we can obtain from UCSC.
hands_on Hands-on: Data upload from UCSC
Search for
UCSC Main
in the tool search bar (top left)
Click on
UCSC Main
toolYou will be taken to the UCSC table browser, which looks something like this:
- Set the following options:
- “clade”:
Mammal
- “genome”:
Mouse
- “assembly”:
July 2007 (NCBI37/mm9)
- “group”:
Genes and Gene Predictions
- “track”:
RefSeq Genes
- “table”:
refGene
- “region”:
genome
- “output format”:
BED - browser extensible data
- “Send output to”:
Galaxy
(only)Click on the get output button
You will see the next screen:
- Make sure that “Create one BED record per” is set to
Whole Gene
- Click on the Send Query to Galaxy button
- Wait for the upload to finish
Rename our dataset to something more recognizable like
Genes
tip Tip: Renaming a dataset
- Add a tag called
#genes
to the dataset to make it easier to track in the history
comment BED file format
The BED - Browser Extensible Data format provides a flexible way to encode gene regions. BED lines have three required fields:
- chromosome ID
- start position (0-based)
- end position (end-exclusive)
There can be up to and nine additional optional fields, but the number of fields per line must be consistent throughout any single set of data.
You can find more information about it at UCSC including a description of the optional fields.
Now we have collected all the data we need to start our analysis.
Part 1: Naive approach
We will first use a “naive” approach to try to identify the genes that the peak regions are associated with. We will identify genes that overlap at least 1bp with the peak regions.
File preparation
Let’s have a look at our files to see what we actually have here.
hands_on Hands-on: View file content
Click on the galaxy-eye (eye) icon (View data) of the peak file to view the content of it
It should look like this:
View the content of the regions of the genes from UCSC
question Questions
While the file from UCSC has labels for the columns, the peak file does not. Can you guess what the columns stand for?
solution Solution
In order to compare the two files, we have to make sure that the chromosome names follow the same format.
As we can see, the peak file lacks chr
before any chromosome number. But what happens with chromosome 20 and 21? Will it be X and Y instead? Let’s check:
hands_on Hands-on: View end of file
- Search for Select last tool tool and run Select last lines from a dataset (tail) with the following settings:
- “Text file”: our peak file
GSE37268_mof3.out.hpeak.txt.gz
- “Operation”:
Keep last lines
- “Number of lines”: Choose a value, e.g.
100
- Click Execute
- Wait for the job to finish
Inspect the file through the galaxy-eye (eye) icon (View data)
question Questions
- How are the chromosomes named?
- How are the chromosomes X and Y named?
solution Solution
In order to convert the chromosome names we have therefore two things to do:
- add
chr
- change 20 and 21 to X and Y
hands_on Hands-on: Adjust chromosome names
- Replace Text Tool: toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_replace_in_column/1.1.3 in a specific column with the following settings:
- “File to process”: our peak file
GSE37268_mof3.out.hpeak.txt.gz
- “in column”:
1
“Find pattern”:
[0-9]+
This will look for numerical digits
“Replace with”:
chr&
&
is a placeholder for the find result of the pattern searchRename your output file
chr prefix added
.- Replace Text Tool: toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_replace_in_column/1.1.3 : Let’s rerun the tool with
- “File to process”: the output from the last run,
chr prefix added
- “in column”:
1
- “Find pattern”:
chr20
- “Replace with”:
chrX
tip Tip: Rerunning a tool
Rename your output file
chrX fixed
- Replace Text Tool: toolshed.g2.bx.psu.edu/repos/bgruening/text_processing/tp_replace_in_column/1.1.3 : Rerun this tool to do the same for chromosome Y
- “File to process”:
chrX fixed
, the output from the last run- “in column”:
1
- “Find pattern”:
chr21
- “Replace with”:
chrY
Inspect the latest file through the galaxy-eye (eye) icon. Have we been successful?
We have quite a few files now and need to take care to select the correct ones at each step.
question Questions
How many regions are in our output file? You can click the name of the output to expand it and see the number.
solution Solution
- Rename the file to something more recognizable, e.g.
Peak regions
Analysis
Our goal is to compare the 2 region files (the genes file and the peak file from the publication) to know which peaks are related to which genes. If you only want to know which peaks are located inside genes (within the gene body) you can skip the next step. Otherwise, it might be reasonable to include the promoter region of the genes into the comparison, e.g. because you want to include transcriptions factors in ChIP-seq experiments. There is no strict definition for promoter region but 2kb upstream of the TSS (start of region) is commonly used. We’ll use the Get Flanks tool to get regions 2kb bases upstream of the start of the gene to 10kb bases downstream of the start (12kb in length). To do this we tell the Get Flanks tool we want regions upstream of the start, with an offset of 10kb, that are 12kb in length, as shown in the diagram below.
hands_on Hands-on: Add promoter region to gene records
- Get Flanks Tool: toolshed.g2.bx.psu.edu/repos/devteam/get_flanks/get_flanks1/1.0.0 returns flanking region/s for every gene, with the following settings:
- “Select data”:
Genes
file from UCSC- “Region”:
Around Start
- “Location of the flanking region/s”:
Upstream
- “Offset”:
10000
- “Length of the flanking region(s)”:
12000
This tool returns flanking regions for every gene
Compare the rows of the resulting BED file with the input to find out how the start and end positions changed
tip Tip: Inspecting several files using the scratchbook
- Rename your dataset to reflect your findings (
Promoter regions
)
The output is regions that start from 2kb upstream of the TSS and include 10kb downstream. For input regions on the positive strand e.g. chr1 134212701 134230065
this gives chr1 134210701 134222701
. For regions on the negative strand e.g. chr1 8349819 9289958
this gives chr1 9279958 9291958
.
You might have noticed that the UCSC file is in BED
format and has a database associated to it. That’s what we want for our peak file as well. The Intersect tool we will use can automatically convert interval files to BED format but we’ll convert our interval file explicitly here to show how this can be achieved with Galaxy.
hands_on Hands-on: Change format and database
- Click on the galaxy-pencil (pencil) icon in the history entry of our peak region file
- Switch to the Convert tab
- Select
Convert Genomic Intervals to BED
- Press Convert datatype
- Check that the “Database/Build” is
mm9
(the database build for mice used in the paper)- Again rename the file to something more recognizable, e.g.
Peak regions BED
It’s time to find the overlapping intervals (finally!). To do that, we want to extract the genes which overlap/intersect with our peaks.
hands_on Hands-on: Find Overlaps
- Intersect Tool: toolshed.g2.bx.psu.edu/repos/devteam/intersect/gops_intersect_1/1.0.0 the intervals of two datasets, with the following settings:
- “Return”:
Overlapping Intervals
- “of”: the UCSC file with promoter regions (
Promoter regions
)- “that intersect”: our peak region file from Replace (
Peak regions BED
)- “for at least”:
1
comment Comments
The order of the inputs is important! We want to end up with a list of genes, so the corresponding dataset with the gene information needs to be the first input (
Promoter regions
).
We now have the list of genes (column 4) overlapping with the peak regions, similar to shown above.
To get a better overview of the genes we obtained, we want to look at their distribution across the different chromosomes. We will group the table by chromosome and count the number of genes with peaks on each chromosome
hands_on Hands-on: Count genes on different chromosomes
- Group Tool: Grouping1 data by a column and perform aggregate operation on other columns with the following settings:
- “Select data” to the result of the intersection
- “Group by column”:
Column 1
- Press Insert Operation and choose:
- “Type”:
Count
- “On column”:
Column 1
- “Round result to nearest integer?”:
No
question Questions
Which chromosome contained the highest number of target genes?
solution Solution
Visualization
Since we have some nice data, let’s draw a barchart out of it!
hands_on Hands-on: Draw barchart
- Click on galaxy-barchart (visualize) icon on the output from the Group tool
- Select
Bar diagram
- Choose a title at Provide a title, e.g.
Gene counts per chromosome
- Switch to the galaxy-chart-select-data Select data tab and play around with the settings
When you are happy, click the galaxy-save Save visualization in the top right of the main panel
This will store it to your saved visualisations where you can later view, download, or share it with others.
Extracting workflow
When you look carefully at your history, you can see that it contains all steps of our analysis, from the beginning to the end. By building this history we have actually built a complete record of our analysis with Galaxy preserving all parameter settings applied at every step. Wouldn’t it be nice to just convert this history into a workflow that we’ll be able to execute again and again?
Galaxy makes this very simple with the Extract workflow
option. This means that any time you want to build a workflow, you can just perform it manually once, and then convert it to a workflow, so that next time it will be a lot less work to do the same analysis. It also allows you to easily share or publish your analysis.
hands_on Hands-on: Extract workflow
Clean up your history
If you had any failed jobs (red), please remove those datasets from your history by clicking on the galaxy-cross (cross) button. This will make the creation of a workflow easier.
- Go to the history History options (galaxy-gear (gear) icon)
Select the
Extract Workflow
option.
The central panel will change and you will be able to choose which steps to include/exclude and how to name the newly created workflow.
Uncheck any steps that shouldn’t be included in the workflow
Since we did some steps which where specific to our custom peak file, we might want to exclude:
- Select last tool
- all Replace Text tool steps
- Convert Genomic Intervals to BED
- Get flanks tool
Rename the workflow to something descriptive, e.g.
From peaks to genes
Click on the Create Workflow button near the top.
You will get a message that the workflow was created. But where did it go?
Click on Workflow in the top menu of Galaxy
Here you have a list of all your workflows
Select the newly generated workflow and click on Edit
You should see something similar to this:
comment The workflow editor
We can examine the workflow in Galaxy’s workflow editor. Here you can view/change the parameter settings of each step, add and remove tools, and connect an output from one tool to the input of another, all in an easy and graphical manner. You can also use this editor to build workflows from scratch.
Although we have our two inputs in the workflow they are missing their connection to the first tool (Intersect tool), because we didn’t carry over some of the intermediate steps.
- Connect each input dataset to the Intersect tool tool by dragging the arrow pointing outwards on the right of its box (which denotes an output) to an arrow on the left of the Intersect box pointing inwards (which denotes an input)
- Rename the input datasets to
Reference regions
andPeak regions
- Click on the galaxy-gear (gear) icon at the top right
- Press Auto Re-layout to clean up our view
- Click on the galaxy-gear (gear) icon at the top right
- Press Save to save your changes
tip Tip: Hiding intermediate steps
Now it’s time to reuse our workflow for a more sophisticated approach.
Part 2: More sophisticated approach
In part 1 we used an overlap definition of 1 bp (default setting) to identify genes associated with the peak regions. However, the peaks could be broad, so instead, in order to get a more meaningful definition, we could identify the genes that overlap where most of the reads are concentrated, the peak summit. We will use the information on the position of the peak summit contained in the original peak file and check for overlap of the summits with genes.
Preparation
We again need our peak file, but we’d like to work in a clean history. Instead of uploading it twice, we can copy it to a new history.
hands_on Hands-on: Copy history items
Create a new history and give it a new name like
Galaxy Introduction Part 2
tip Tip: Creating a new history
Click on the View all histories (galaxy-columns icon) at the top right of your history
You should see both of your histories side-by-side now
- Drag and drop the edited peak file (
Peak regions
, after the replace steps), which contains the summit information, to your new history.- Click on Analyze Data in the top menu bar to go back to your analysis window
Create peak summit file
We need to generate a new BED file from the original peak file that contains the positions of the peak summits. The start of the summit is the start of the peak (column 2) plus the location within the peak that has the highest hypothetical DNA fragment coverage (column 5). As the end of the peak region, we will simply define start + 1
.
hands_on Hands-on: Create peak summit file
- Compute an expression on every row Tool: toolshed.g2.bx.psu.edu/repos/devteam/column_maker/Add_a_column1/1.3.0 with the following parameters:
- “Add expression”:
c2+c5
- “as a new column to”: our peak file
Peak regions
(the interval format file)- “Round result?”:
YES
This will create an 8th column in our table, which we will use in our next step:
Rename the output
Peak regions new column
- Compute an expression on every row Tool: toolshed.g2.bx.psu.edu/repos/devteam/column_maker/Add_a_column1/1.3.0 rerun this tool on the last result with:
- “Add expression”:
c8+1
- “as a new column to”: the
Peak regions new column
file we just created- “Round result?”:
YES
- Rename this file
Peak summit regions
Now we cut out just the chromosome plus the start and end of the summit:
hands_on Hands-on: Cut out columns
- Cut Tool: cut1 columns from a table with the following settings:
- “Cut columns”:
c1,c8,c9
- “Delimited by Tab”:
Tab
- “From”:
Peak summit regions
The output from Cut will be in
tabular
format.Change the format to
interval
(use the galaxy-pencil) since that’s what the tool Intersect expects.tip Tip: Changing the datatype
The output should look like below:
Get gene names
The RefSeq genes we downloaded from UCSC did only contain the RefSeq identifiers, but not the gene names. To get a list of gene names in the end, we use another BED file from the Data Libraries.
comment Comments
There are several ways to get the gene names in, if you need to do it yourself. One way is to retrieve a mapping through Biomart and then join the two files (Join two Datasets side by side on a specified field tool). Another is to get the full RefSeq table from UCSC and manually convert it to BED format.
hands_on Hands-on: Data upload
Import Tool: upload1
mm9.RefSeq_genes_from_UCSC.bed
from Zenodo or from the data library:https://zenodo.org/record/1025586/files/mm9.RefSeq_genes_from_UCSC.bed
tip Tip: Importing data via links
tip Tip: Importing data from a data library
As default, Galaxy takes the link as name, so rename them.
Inspect the file content to check if it contains gene names. It should look similar to below:
- Rename it
mm9.RefSeq_genes
- Apply the tag
#genes
Repeat workflow
It’s time to reuse the workflow we created earlier.
hands_on Hands-on: Run a workflow
- Open the workflow menu (top menu bar)
- Find the workflow you made in the previous section, and select the option Run
- Choose as inputs our
mm9.RefSeq_genes
(#genes
) BED file and the result of the Cut tool (#peaks
)Click Run workflow
The outputs should appear in the history but it might take some time until they are finished.
We used our workflow to rerun our analysis with the peak summits. The Group tool again produced a list containing the number of genes found in each chromosome. But wouldn’t it be more interesting to know the number of peaks in each unique gene? Let’s rerun the workflow with different settings!
hands_on Hands-on: Run a workflow with changed settings
- Open the workflow menu (top menu bar)
- Find the workflow you made in the previous section, and select the option Run
- Choose as inputs our
mm9.RefSeq_genes
(#genes
) BED file and the result of the Cut tool (#peaks
)- Click on the title of the tool Group tool to expand the options.
- Change the following settings by clicking on the galaxy-pencil (pencil) icon on the left:
- “Group by column”:
7
- In “Operation”:
- “On column”:
7
- Click Run workflow
Congratulations! You should have a file with all the unique gene names and a count on how many peaks they contained.
question Questions
The list of unique genes is not sorted. Try to sort it on your own!
solution Solution
Share your work
One of the most important features of Galaxy comes at the end of an analysis. When you have published striking findings, it is important that other researchers are able to reproduce your in-silico experiment. Galaxy enables users to easily share their workflows and histories with others.
To share a history, click on the galaxy-gear (gear) symbol in the history pane and select Share or Publish
. On this page you can do 3 things:
-
Make accessible via Link
This generates a link that you can give out to others. Anybody with this link will be able to view your history.
-
Publish History
This will not only create a link, but will also publish your history. This means your history will be listed under
Shared Data → Published Histories
in the top menu. -
Share with Individual Users
This will share the history only with specific users on the Galaxy instance.
hands_on Hands-on: Share history and workflow
- Share one of your histories with your neighbour
- See if you can do the same with your workflow!
Find the history and/or workflow shared by your neighbour
Histories shared with specific users can be accessed by those users in their history menu (galaxy-gear (gear) icon) under
Histories shared with me
.
Conclusion
trophy You have just performed your first analysis in Galaxy. You also created a workflow from your analysis so you can easily repeat the exact same analysis on other datasets. Additionally you shared your results and methods with others.
keypoints Key points
Galaxy provides an easy-to-use graphical user interface for often complex commandline tools
Galaxy keeps a full record of your analysis in a history
Workflows enable you to repeat your analysis on different data
Galaxy can connect to external sources for data import and visualization purposes
Galaxy provides ways to share your results and methods with others
References
- Li, X., L. Li, R. Pandey, J. S. Byun, K. Gardner et al., 2012 The Histone Acetyltransferase MOF Is a Key Regulator of the Embryonic Stem Cell Core Transcriptional Network. Cell Stem Cell 11: 163–178. 10.1016/j.stem.2012.04.023
Feedback
Did you use this material as an instructor? Feel free to give us feedback on how it went.
Citing this Tutorial
- Anne Pajon, Clemens Blank, Bérénice Batut, Björn Grüning, Nicola Soranzo, Dilmurat Yusuf, Sarah Peter, Helena Rasche, 2020 From peaks to genes (Galaxy Training Materials). /archive/2021-02-01/topics/introduction/tutorials/galaxy-intro-peaks2genes/tutorial.html Online; accessed Tue Apr 01 2025
- Batut et al., 2018 Community-Driven Data Analysis Training for Biology Cell Systems 10.1016/j.cels.2018.05.012
details BibTeX