R Bioinformatics Cookbook - Second Edition

Book description

Discover over 80 recipes for modeling and handling real-life biological data using modern libraries from the R ecosystem

Key Features

  • Apply modern R packages to process biological data using real-world examples
  • Represent biological data with advanced visualizations and workflows suitable for research and publications
  • Solve real-world bioinformatics problems such as transcriptomics, genomics, and phylogenetics
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

The updated second edition of R Bioinformatics Cookbook takes a recipe-based approach to show you how to conduct practical research and analysis in computational biology with R. You’ll learn how to create a useful and modular R working environment, along with loading, cleaning, and analyzing data using the most up-to-date Bioconductor, ggplot2, and tidyverse tools.

This book will walk you through the Bioconductor tools necessary for you to understand and carry out protocols in RNA-seq and ChIP-seq, phylogenetics, genomics, gene search, gene annotation, statistical analysis, and sequence analysis. As you advance, you'll find out how to use Quarto to create data-rich reports, presentations, and websites, as well as get a clear understanding of how machine learning techniques can be applied in the bioinformatics domain. The concluding chapters will help you develop proficiency in key skills, such as gene annotation analysis and functional programming in purrr and base R. Finally, you'll discover how to use the latest AI tools, including ChatGPT, to generate, edit, and understand R code and draft workflows for complex analyses.

By the end of this book, you'll have gained a solid understanding of the skills and techniques needed to become a bioinformatics specialist and efficiently work with large and complex bioinformatics datasets.

What you will learn

  • Set up a working environment for bioinformatics analysis with R
  • Import, clean, and organize bioinformatics data using tidyr
  • Create publication-quality plots, reports, and presentations using ggplot2 and Quarto
  • Analyze RNA-seq, ChIP-seq, genomics, and next-generation genetics with Bioconductor
  • Search for genes and proteins by performing phylogenetics and gene annotation
  • Apply ML techniques to bioinformatics data using mlr3
  • Streamline programmatic work using iterators and functional tools in the base R and purrr packages
  • Use ChatGPT to create, annotate, and debug code and workflows

Who this book is for

This book is for bioinformaticians, data analysts, researchers, and R developers who want to address intermediate-to-advanced biological and bioinformatics problems by learning via a recipe-based approach. Working knowledge of the R programming language and basic knowledge of bioinformatics are prerequisites.

Table of contents

  1. R Bioinformatics Cookbook, Second Edition
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share Your Thoughts
    8. Download a free PDF copy of this book
  6. Chapter 1: Setting Up Your R Bioinformatics Working Environment
    1. Technical requirements
      1. Further information
    2. Setting up an R project in a directory
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Using the here package to simplify working with paths
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Using the devtools package to work with the latest non-CRAN packages
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Setting up your machine for the compilation of source packages
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    6. Using the renv package to create a project-specific set of packages
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Installing and managing different versions of Bioconductor packages in environments
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Using bioconda to install external tools
      1. swGetting ready
      2. How to do it…
      3. How it works…
  7. Chapter 2: Loading, Tidying, and Cleaning Data in the tidyverse
    1. Technical requirements
      1. Further information
    2. Loading data from files with readr
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    3. Tidying a wide format table into a tidy table with tidyr
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    4. Tidying a long format table into a tidy table with tidyr
      1. Getting ready
      2. How it works…
      3. There’s more…
    5. Combining tables using join functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Reformatting and extracting existing data into new columns using stringr
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Computing new data columns from existing ones and applying arbitrary functions using mutate()
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Using dplyr to summarize data in large tables
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Using datapasta to create R objects from cut-and-paste data
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  8. Chapter 3: ggplot2 and Extensions for Publication Quality Plots
    1. Technical requirements
      1. Further information
    2. Combining many plot types in ggplot2
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Comparing changes in distributions with ggridges
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Customizing plots with ggeasy
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Highlighting selected values in busy plots with gghighlight
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Plotting variability and confidence intervals better with ggdist
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Making interactive plots with plotly
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    8. Clarifying label placement with ggrepel
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Zooming and making callouts from selected plot sections with facetzoom
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. Getting ready
      5. How to do it…
      6. How it works…
      7. There’s more…
      8. See also
  9. Chapter 4: Using Quarto to Make Data-Rich Reports, Presentations, and Websites
    1. Technical requirements
      1. Further information
    2. Using Markdown and Quarto for literate computation
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Creating different document formats from the same source
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Creating data-rich presentations from code
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Creating websites from collections of Quarto documents
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    6. Adding interactivity with Shiny
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
  10. Chapter 5: Easily Performing Statistical Tests Using Linear Models
    1. Technical requirements
      1. Further information
    2. Modeling data with a linear model
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Using a linear model to compare the mean of two groups
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Using a linear model and ANOVA to compare multiple groups in a single variable
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Using linear models and ANOVA to compare multiple groups in multiple variables
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Testing and accounting for interactions between variables in linear models
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Doing tests for differences in data in two categorical variables
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Making predictions using linear models
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
  11. Chapter 6: Performing Quantitative RNA-seq
    1. Technical requirements
      1. Further information
    2. Estimating differential expression with edgeR
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Estimating differential expression with DESeq2
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more...
    4. Estimating differential expression with Kallisto and Sleuth
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Using Sleuth to analyze time course experiments
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Analyzing splice variants with SGSeq
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Performing power analysis with powsimR
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Finding unannotated transcribed regions
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    9. Finding regions showing high expression ab initio using bumphunter
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    10. Differential peak analysis
      1. Getting ready
      2. How to do it…
      3. How it works…
    11. Estimating batch effects with SVA
      1. Getting ready
      2. How to do it…
      3. How it works…
    12. Finding allele-specific expression with AllelicImbalance
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    13. Presenting RNA-Seq data using ComplexHeatmap
      1. Getting ready
      2. How to do it…
      3. How it works…
  12. Chapter 7: Finding Genetic Variants with HTS Data
    1. Technical requirements
      1. Further information
    2. Finding SNPs and INDELs from sequence data using VariantTools
    3. Getting ready
      1. How to do it…
      2. How it works…
      3. There’s more…
      4. See also
    4. Predicting open reading frames in long reference sequences
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Plotting features on genetic maps with karyoploteR
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    6. Selecting and classifying variants with VariantAnnotation
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    7. Extracting information in genomic regions of interest
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Finding phenotype and genotype associations with GWAS
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Estimating the copy number at a locus of interest
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
  13. Chapter 8: Searching Gene and Protein Sequences for Domains and Motifs
    1. Technical requirements
      1. Further information
    2. Finding DNA motifs with universalmotif
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Finding protein domains with PFAM and bio3d
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Finding InterPro domains
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also…
    5. Finding transmembrane domains with tmhmm and pureseqTM
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also
    6. Creating figures of protein domains using drawProteins
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Performing multiple alignments of proteins or genes
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    8. Aligning genomic length sequences with DECIPHER
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Novel feature detection in proteins
      1. Getting ready
      2. How to do it…
      3. How it works…
    10. 3D structure protein alignment in bio3d
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  14. Chapter 9: Phylogenetic Analysis and Visualization
    1. Technical requirements
      1. Further information
    2. Reading and writing varied tree formats with ape and treeio
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    3. Visualizing trees of many genes quickly with ggtree
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Quantifying and estimating the differences between trees with treespace
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    5. Extracting and working with subtrees using ape
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    6. Creating dot plots for alignment visualizations
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Reconstructing trees from alignments using phangorn
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Finding orthologue candidates using reciprocal BLASTs
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
  15. Chapter 10: Analyzing Gene Annotations
    1. Technical requirements
      1. Further information
    2. Retrieving gene and genome annotations from BioMart
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Getting Gene Ontology information for functional analysis from appropriate databases
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Using AnnoDB packages for genome annotation
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    5. Using ClusterProfiler for determining GO enrichment in clusters
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Finding GO enrichment in an Ontology Conditional way with topGO
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Finding enriched KEGG pathways
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Retrieving and working with SNPs
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
  16. Chapter 11: Machine Learning with mlr3
    1. Technical requirements
      1. Further information
    2. Defining a task and learner to implement k-nearest neighbors (k-NNs) in mlr3
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
      5. See also...
    3. Testing the fit of the model using cross-validation
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    4. Using logistic regression to classify the relative likelihood of two outcomes
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    5. Classifying using random forest and interpreting it with iml
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Dimension reduction with PCA in mlr3 pipelines
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Creating a tSNE and UMAP embedding
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Clustering with k-means and hierarchical clustering
      1. Getting ready
      2. How to do it…
      3. How it works…
  17. Chapter 12: Functional Programming with purrr and base R
    1. Technical requirements
      1. Further information
    2. Making base R objects “tidy”
      1. Getting ready
      2. How to do it…
      3. How it works…
    3. Using nested dataframes for functional programming
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. See also
    4. Using the apply family of functions
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Using the map family of functions in purrr
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Working with lists in purrr
      1. Getting ready
      2. How to do it…
      3. How it works…
  18. Chapter 13: Turbo-Charging Development in R with ChatGPT
    1. Technical requirements
      1. Further information
    2. Interpreting complicated code with ChatGPT assistance
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    3. Debugging and improving code with ChatGPT
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Generating code with ChatGPT
    5. Getting ready
      1. How to do it…
      2. How it works…
      3. There’s more…
    6. Writing documentation for R functions with ChatGPT
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more…
    7. Writing unit tests for R functions with ChatGPT
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Finding R packages to build a workflow with ChatGPT
      1. Getting ready
      2. How to do it…
      3. How it works…
  19. Index
    1. Why subscribe?
  20. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: R Bioinformatics Cookbook - Second Edition
  • Author(s): Dan MacLean
  • Release date: October 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781837634279