Go back to the main page
Go back to the R overview page
R
Data Visualization Exercises
This file can be found here.
The exercises will be similar to the exercises in Excel in order to compare the results.
Exercise 1
Load the following dataset.
The data frame shows RNA expression data with and without a
stimulus.
Create a column chart for the MAP kinase Expression values
without a stimulus with expression levels higher than
0.5.
Annotate the axis and add a proper title.
Sort the expression values from low to high (the graph should
contain bars with increasing height).
Which three gene names have the highest Expression Value without a stimulus?
Exercise 2
From the previous data set, use again the gene expression within the
MAP Kinase gene family.
Create a clustered column chart representing the
expression values without stimulus and the expression values with
stimulus. Make sure to add proper axis titles, a title and a legend.
Exercise 3
Use the same data as from exercise 2 to create a stacked column chart in which each column represents a gene family from the motor proteins (i.e. dynein, kinesin and myosin) and the segments within each column show the number of genes whose expression is increased or decrease in the presence of the stimulus. Before you can create this chart, you need to analyse the data: - Create a new column, with an appropriate name, in which you use the IF-function to indicate for each gene family whether the expression is increased or decreased. - In a new sheet, use the COUNTIFS-function to count for each motor protein gene family the number of genes whose expression is increased or decreased in the presence of the stimulus. For example (the values in this table are not correct)
| Protein | Increased | Decreased |
|---|---|---|
| Dynein | 6 | 7 |
| Kinesin | 11 | 3 |
| Myosin | 4 | 12 |
If a gene is not increased or decreased, it should not be counted (we are not interested in unaltered genes). Note that in this case, only a true zero counts as unchanged. In reality, to isolate meaningfully altered genes, researchers filter out background noise using a volcano-plot approach that requires genes to meet both a statistical threshold (adjusted \(p\)-value) and a biological effect-size threshold (\(\log_2\) fold change) before downstream analysis.
Exercise 4
Use the same data as from exercise 3 to create a relative stacked column chart in which each column represents a gene family from the motor proteins (i.e. dynein, kinesin and myosin) and the segments within each column percentage of genes whose expression is increased or decreased in the presence of the stimulus. Make sure to add proper axis titles, a title and a legend. The gene names should be sorted.
Exercise 5
In the dataset, each protein belongs to a gene family, and each gene family is classified under a particular category. Create a pie chart representing the contribution of the different gene families within the category “Immuno system proteins”.
Before creating the chart, analyze the data in R:
Filter the data: Subset the dataset to keep only the entries belonging to the “Immune system proteins” category.
Summarize the counts: Determine the unique gene families in this subset and count the number of genes in each family.
Generate the chart: Map the aggregated counts to a polar bar chart in ggplot2 to display the pie chart.
Exercise 6
For this exercise you will use the same data.
Create a box plot for Expression value without stimulus
plotted against the Categories.
Which category shows the lowest median value?
Exercise 7
For this exercise you will use the same data.
Create a grouped box plot for
Expression value without stimulus vs
Expression Value with stimulus.
Which category shows the lowest IQR value?
Exercise 8
In this dataset you can find Chick Weight data. It shows the weight (in grams) on day 42 for various chickens that were fed with various diets during 42 days.
Create a radar chart for the various diets on day
42.
Calculate the average weight per diet.
Two Chickens on a certain diet clearly gained the most weight.
Which two chickens on which diet generated the highest weight gains?
Exercise 9
Have look at the data here It contains data about Potassium and Sodium concentrations (in mmol/L) as well as body weight (in kg) for various persons.
Create a bubble chart with the Na concentration as a
function of the K concentration.
The bubble size should be based on the body weight.
As you can see, there is a correlation between the sodium and potassium concentration but there is one person who can be considered an outlier. What is the name of this person?
Exercise 10
In this dataset, you will find data on the velocity of an enzymatic reaction were obtained by Treloar (1974). The number of counts per minute of radioactive product from the reaction was measured as a function of substrate concentration in parts per million (ppm) and from these counts the initial rate (or velocity) of the reaction was calculated (counts/min). The experiment was conducted once with the enzyme treated with Puromycin, and once with the enzyme untreated.
Create a XY-scatter plot with the velocity plotted against the substrate concentration.
Create a XY-scatter plot for the experiment without puromycin and an additional XY scatter plot for both (with and without puromycin) conditions.
Does puromycin act as an inhibitor or an activator for this enzyme?
Exercise 11
For this exercise, we will use the data set from an earlier exercise again. This time, create a pivot table and pivot plot.
Download the data set.
Create a pivot plot for the mean
Expression Value plotted against the
Categories (both with and without stimulus).
What category shows the lowest expression values and what category shows the highest expression values?
Go back to the main page
Go back to the R overview page
⬆️ Back to Top
This web page is distributed under the terms of the Creative Commons Attribution License which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. Creative Commons License: CC BY-SA 4.0.