Chapter 13 Scripts

These scripts are contributed from the NDCN community during office hours hackathons, etc. They are available for remix/reuse by other community members.

13.1 hackathon R scripts

13.2 RNAseq quality control

13.3 tidy data R script: expression data

  • olivertam/NDCN_tidyData. Short script imports expression data (wide format with row names) and uses 2 tidyr functions: rownames_to_column() and pivot_longer() to transform to tidy data. Then, we do a preliminary plot to help think of next steps. Oliver’s repo includes data required to run to code below.
library(tidyverse)

data <- read.table("exprData.txt",sep="\t",header=TRUE,row.names=1)

tidyData <- data %>%
    rownames_to_column(var = "geneSymbol") %>%
    pivot_longer(
        cols = sample1_neuron:sample3_others,
        names_to = c("sample","celltype"),
        names_pattern = "(.*)_(.*)",
        values_to = "count"
    )
p <- ggplot(data = tidyData, aes(x = celltype, y = count, fill = sample)) + geom_violin()
p