Exercise 1

ggplot(SNPs, aes(chromosome))+
  geom_bar(fill="blue")+
  ggtitle("SNPs per Chromosome")+
  ylab("Count")+
  xlab("Chromosomes")

Exercise 2

 colp=c("DI"="red",
           "D"="red",
           "DD"="red",
           "I"="red",
           "II"="red",
           "--"="red",
           "A" = "blue",
           "G" = "blue",
           "T" = "blue",
           "C" = "blue",
          "AA" = "green",
          "AG" = "green",
          "AC"="green",
          "AT"="green",
          "CG" = "green",
          "CC"="green",
          "CT"="green",
          "GG" = "green",
          "GT"="green",
          "TT"="green"
          )
ggplot(SNPs, aes(chromosome, fill=genotype))+
  geom_bar()+
  ggtitle("SNPs per Chromosome by Genotype")+
  ylab("Count")+
  xlab("Chromosomes")+
  scale_fill_manual(values = colp)

Exercise 3

ppi <- 300
png("SNP_example_plot.png", width=6*ppi, height=6*ppi, res=ppi)
ggplot(SNPs, aes(chromosome, fill=genotype))+
  geom_bar(position="dodge")+
  ggtitle("SNPs per Chromosome by Genotype")+
  ylab("Count")+
  xlab("Chromosomes")
dev.off()
## quartz_off_screen 
##                 2
Genotype counts per chromosome

Genotype counts per chromosome

Exercise 4

ggplot(SNPs, aes(chromosome, fill=genotype))+
  geom_bar(position="dodge")+
  facet_wrap(SNPs$genotype, ncol=3)+
  ggtitle("SNPs per Chromosome by Genotype")+
  ylab("Count")+
  xlab("Chromosomes")

Exercise 5

ggplotly(
  ggplot(SNPs, aes(chromosome, fill=genotype))+
  geom_bar(position="dodge")+
  facet_wrap(SNPs$genotype)+
  ggtitle("SNPs per Chromosome by Genotype")+
  ylab("Count")+
  xlab("Chromosomes")
  )

Exercise 6

subSNP=subset(SNPs, chromosome=="Y")
datatable(subSNP)
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html