library(tidyverse)
library(patchwork)

Q1

gene_expression <- read_csv("~/wsbim-bioinfo/gene_expression.csv")

# base R

boxplot(gene_expression)

hist(gene_expression[[1]])
hist(gene_expression[[2]])
hist(gene_expression[[3]])

# ggplot

gene_expression_long <- pivot_longer(gene_expression,
                                     names_to = "gene",
                                     values_to = "expression",
                                     everything())

x1 <- ggplot(gene_expression_long, aes(x=gene, y = expression, fill = gene)) +
  geom_boxplot()

x2 <- ggplot(gene_expression_long, aes(x=gene, y = expression, fill = gene)) +
  geom_violin()

x3 <- ggplot(gene_expression_long, aes(x=expression, fill = gene)) + 
  geom_histogram() +
  facet_grid(gene ~ .)

x1 + x2 + x3

Q2

TF_to_TK <- function(TF) {
  TK <- (TF-32)*5/9+273.15
  return(TK) }

TF_to_TK(123)

Q4

apply1 <- read_csv("~/wsbim-bioinfo/apply1.csv")

mean(rowSums(apply1))
median(colSums(apply1))

mean(apply(apply1,1,sum))
median(apply(apply1,2,sum))