setwd("/Users/ianglavin/Documents/bin501/week2")
myGex <- read.table("ENCFF166SFX.tsv", header = TRUE)
# this graph shows the distribution of gene lenghts across the ENCODE dataset
library(ggplot2)
ggplot(myGex, aes(x = length)) +
  geom_histogram(binwidth = 50, fill = "orange") +
  labs(title = "Distribution of Gene Lengths")

# The graph shows the distribution of gene lengths in the ENCODE brain tissue dataset, limited to genes shorter than 10,000 bases. Also shows that shorter genes are more common.
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
normalLength <- myGex |>
  filter(`length` < 10000)
ggplot(normalLength, aes(x = `length`)) +
  geom_histogram(binwidth = 1000, fill = "orange") +
  labs(title = "Modified Distribution of Gene Lengths")

# create a bar graph showing genes with high expression in the brain tissue sample.
hiEx <- myGex |>
  filter(FPKM > 5000)
ggplot(hiEx, aes(x = gene_id, y = FPKM, fill = FPKM)) +
  geom_col() +
  scale_fill_gradient(low = "orange", high = "red") +
  theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) +
  labs(title = "Highly Expressed Genes in Brain Tissue")

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.