16.4 Exercise 3

In this short exercise, you will practice using the functions for data manipulation we just learned.

We will start from gtf.

If gtf it is no longer in your environment, load it with:

gtf <- read_csv("GSE277039/gencode.vM38.annotation_sample.csv")

Save the result of each step into intermediate objects.

  1. Rename column chr as Chromosome. Assign to a new object.
correction
gtf2 <- rename(gtf, Chromosome=chr)
# if there is a conflict in the packages, try calling explicitely the rename function from dplyr package: 
gtf2 <- dplyr::rename(gtf, Chromosome=chr)


2. Keep rows with “+” strand on chromosome “chr4”. Assign this filtered data to a new object.

correction
gtf3 <- filter(gtf2, strand=="+" & Chromosome=="chr4")


  1. Remove columns strand and gene_type.
correction
gtf4 <- select(gtf3, -strand, -gene_type)