Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

January 6, 2026

Setting up Ubuntu 24.04.x LTS desktop and server, RStudio server, and JypyterLab at home

Why? Set up a Linux server computer on a home network if:

  • You want to run code that takes a long time to complete. Let it run on the server computer so you can use your main computer for other things.
  • Your main computer is low on storage space. Upload all data files to the server and you can run analysis on the server remotely, e.g. from a laptop while you sit on your couch.
  • You want a server specifically for Linux (e.g. for bioinformatics or programming purposes), whereas your main computer is Windows or MacOS.

Who? This tutorial is intended for computer-savvy people with enough patience and knowledge to troubleshoot their own computer by searching the internet for error codes and following instructions. Ideally, you should have some programming experience (beginner level in any language is enough) and know about terminals or command prompt windows, but you can learn what you need as you go. This is a great hands-on way to learn to use Linux. Expert Linux knowledge is not a prerequisite. 

What? Ubuntu Desktop 24.04.x LTS "Noble Numbat" (or the latest version), OpenSSH for server capabilities, RStudio server, and Jupyter Lab. Ubuntu is a specific version of Linux.

Cost? All the software is free. For hardware, you need the following:

October 10, 2024

Bookmarks: single cell RNA-seq tutorials and tools

These are my bookmarks for single cell transcriptomics resources and tutorials. Whenever I find something useful, I add it.

scRNA-seq introductions

How to make R objects for single cell data, e.g. SingleCellExperiment, SummarizedExperiment  

Getting Started with Seurat v4  (Satija lab tutorials list)

  • Many tutorials here, for different scRNA-seq goals

Guided clustering tutorial with 3000 PBMC cells

  • Setup Seurat object
  • Standard pre-processing workflow & quality control
  • Data normalization
  • Identifying highly variable features (genes)
  • Clustering, UMAP/tSNE plots
  • Differential gene expression analysis

Basics of single cell analysis with Bioconductor

University of Cambridge intro to single cell RNA-seq analysis

  • Identification of low-quality cells using MADs values

 
  • "Annotation inherits every upstream decision, so good labels start before labelling. A standard scRNA-seq workflow moves from cell isolation and barcoding to a gene-by-cell count matrix, followed by filtering, normalisation, dimensionality reduction with PCA, and graph-based clustering with Leiden or Louvain on a k-nearest-neighbour graph. If quality control is weak, ambient RNA remains uncorrected, doublets stay in the data, or batch structure dominates, those problems become part of the clusters. Careful labelling cannot rescue a bad clustering structure."

September 20, 2024

How to get MD5 checksums to detect data corruption (for bioinformatics data curation)

What are MD5 checksums? Checksums are nonsense text strings used to "summarize" a file version. No matter the size of the file (1 kb or 30 GB), the checksum algorithm gives you a conveniently short nonsense string of letters and numbers. The exact same file will give you the exact same checksum every time. If you change a single character or pixel, you will get a different checksum.

MD5 is a specific popular algorithm to get checksums.

Why use checksums? The purpose of checksums is to notice data corruption, especially when downloading files from or uploading files to a server. Every time you transfer files between computers, there is risk of data corruption. For small files, the risk is small and you'll most likely notice, for example if your email attachment download fails due to an internet interruption. 

For large files such as raw sequencing data files, it's a bigger issue and you might not notice right away (or ever) if the last few RNA-seq reads of a >30 million reads file are missing. Therefore, the best practice when downloading new sequencing is to create MD5 checksums yourself and compare them with the MD5 checksum created by the originating computer (the sequencing core's server). They should be the same. If not, something went wrong during file transfer! Try re-downloading the data.

Similarly, when you upload sequencing data to a public repository (e.g. NCBI GEO), you provide MD5 checksums so that the receivers (NCBI's data curators) can confirm the upload was successful.

How to get an MD5 checksum for an individual file? See example below using the Linux terminal. I created a text file containing only the phrase "hello pretend this is sequencing data". The checksum for that file is "b088d8d4d1d831af2d8d16147389aa7d". If I change the first letter to uppercase, the checksum completely changes.

 

March 26, 2024

Advice: Flash talks

What is a flash talk?

Flash talks are brief formal presentations about your research, usually 1-3 minutes. They are mini-oral presentations to accompany research posters or journal articles. Other names include lightning talks, speed talks, rapid-fire talks. Their goal is to provide big picture ideas and make your research interesting to a broad audience.

They are similar to elevator pitches, except flash talks include a visual element (usually 1-3 PowerPoint slides). Sometimes the visual element is your full poster and nothing else, in which case you want to design your poster with this in mind. Add large visuals and large text.

Advice for flash talks (video links):

Winning Tips for Preparing a Successful Three-Minute Thesis 3MT® Presentation, OhioUPhysics, YouTube [12:32]

How to give a flash talk - tips and tricks for scientists, European Molecular Biology Laboratory (EMBL), YouTube [2:58]

The perfect pitch - explaining your research in one minute, Kungl. Ingenjörsvetenskapsakademien IVA, YouTube [7:32]

July 2, 2023

How to find journal articles, full text and pdf

This is how to find scientific papers when you are doing a literature review (or "lit review" or "lit search"). I recommend using multiple methods because each has its limitations. A multi-website approach will give you better results.

PubMed

PubMed.gov is the National Institutes of Health (NIH) government-funded search engine for biomedical research, biology, chemistry, and other topics of interest to human health. It indexes specific journals that fit this criteria and any articles (human-focused or not) that are published in those journals. For example, my plant RNA regulation and alternative splicing paper is indexed on PubMed. Plant research is relevant for human health as well, from nutrition to medical advances. PubMed thus includes a lot of basic biology research and sociology research.

PubMed provides links to articles for the original publisher's website (which might be behind a paywall) and links to PubMed Central (which releases articles free to the public after 1 year post-publication, if the research is NIH-funded). PubMed Central is a great way to get free access to NIH-funded research articles.

March 29, 2023

How to pick random samples from a list with Excel

Scenario: You have a list of 50 samples per group that meet criteria for your RNA-seq study, but you only want to sequence 20 per group. How do you randomly pick 20 per group? Also, how do you randomly order them for sequencing?

Random selection with Excel:

  1. In your spreadsheet with all eligible samples, have a column for each sample's group (e.g. IVF, NIFT, Spontaneous; Female, Male; Overweight, Normal, Underweight; et cetera). It needs to be a categorical variable, not discrete or continuous numbers.
  2. Add a new column and label it "RandomNum"
  3. Fill the "RandomNum" column with =RAND() and press enter to generate random numbers
  4. Copy the "RandomNum" column and re-paste as values to remove the formula, otherwise it re-calculates each time you open the spreadsheet
  5. Sort by the random number, then the group, and pick 20 from each group that way
  6. Make a new column "Include" and fill in yes/no

Make the final selection:

  1. Check criteria demographics of your randomly selected groups. Swap out Include=yes and Include=no samples if needed to fix any obvious imbalances or remove obvious outliers. For example, when comparing fetal sex, we try to also balance fetal race. Another example: if the maternal age range is 30-40 in one group, and similar in the other group except for one outlier age 23, we may swap that outlier for a different subject.
  2. Don't balance demographics that might be related to your study variable (and keep in mind you don't always know which are related). For example, for our study of infertility looking at IVF and non-IVF treatment subgroups, the non-IVF treatment group had a higher BMI than both the IVF and the no treatment control group. We did not balance for BMI because anything metabolic can be related to fertility. 
  3. Don't balance outcome demographics. For example, for our study of first trimester placenta gene expression, we tried to balance fetal sex and gestational age at first trimester sampling time, but we did not balance birth weight because that is a study outcome (appears after our first trimester sampling timepoint). In fact, males tend to be heavier than females at birth. 

Random order with Excel:

  1. Sort the spreadsheet by the random number again and then sort by column "Include" so you have all the Include=yes samples together
  2. Make a new column "Order" and fill in with 1,2,3,4,5,...,38,39,40 (example assuming two groups of 20) to randomize the order of the samples for sequencing

November 22, 2022

Advice: Raw data storage for bioinformatics (terabytes of data)

Good habits and advice

  • Download sequencing data from the sequencing core or company within 30 days of receiving it. They won't store it forever! 
  • Keep multiple copies of your important data.
  • Don't open your original results spreadsheet files with Excel - make copies specifically to open with Excel to avoid autosaving corrupted or filtered data. Beware the Excel calendar issue with gene names.
  • Always eject or unmount data drives to prevent data corruption. Do this before you unplug them physically.
  • Check MD5 checksums. This helps you detect data corruption during downloads, storage, uploads, etc. If you find a mismatch, you can re-download or re-upload to correct it.

Drive formatting

October 24, 2022

Advice: Poster preparation and printing for research conferences

Advice for how to make a poster (technical stuff like what software to use, what sizes to use, how to make a high resolution pdf for printing) and where to get it printed.

August 24, 2022

R programming lesson #1: load data, subset, and write to a new file

See also: "How to get started with R programming"

Purpose: 

Learn to prepare an Excel spreadsheet for data import, re-save as a .csv file, load into R, look at the data, subset to significant genes, and write the smaller spreadsheet to a new .csv file.

April 21, 2022

R code: Reading single spreadsheets and merging them into a multi-sheet Excel file

This R code example shows how to automatically compile multiple csv spreadsheets (or csv-formatted simple Excel spreadsheets) into one multi-sheet Excel spreadsheet. Personally, I use this to combine datasets from Ingenuity Pathways Analysis for supplemental files. I can do it manually but I always worry that I'll accidentally open the wrong analysis file or mis-name the tab. 

This way, I have a record of what files became what named sheets. I can also quickly re-compile a new Excel results file if I rerun the analysis by just changing the filenames in this code.

Packages

I prefer gdata for reading Excel sheets (better support for special characters) and openxlsx for writing the multi-sheet Excel file. 

Although gdata requires Perl installed on your computer, it does not require any knowledge of the Perl programming language. Use Strawberry Perl for Windows. Linux already has Perl.

The openxlsx package does not require any additional installations.
#install.packages("gdata")
#install.packages("openxlsx")

library(gdata)  ## for read.xls() function; requires perl
library(openxlsx)

March 17, 2022

Why do we adjust p-values for multiple comparisons in big data analysis?

For RNA-sequencing, DNA methylation arrays, GWAS, and other big data projects, we run a statistical test to compare two groups for each row in the data matrix (each gene, each methylation site, each SNP, etc). That gives us a p-value for each reading. 

However, with big data, p<0.05 is only suggestive, not sufficiently strict. When working with thousands (miRNA-seq), tens of thousands (mRNA-seq or total RNA-seq), or >450,000 sites (DNA methylation), the occurence of false positives is much greater. This webcomic shows why we don't rely only on simple p-values to make conclusions: "Significant" (xkcd #882)

To reduce risk of false positives and narrow down to significant values, we adjust the original p-values for multiple comparisons. These two methods are popular:

  • Benjamini-Hochberg's False Discovery Rate (FDR)
    • Most common p-value adjustment for RNA-seq data.
    • Sometimes used for DNA methylation data.
    • Citation: Benjamini, Y., & Hochberg, Y. (1995). "Controlling the false discovery rate: a practical and powerful approach to multiple testing." Journal of the Royal Statistical Society. Series B (Methodological), 57(1):289-300.
    • In R, make a new "FDR" column in your complete dataset using the full list of p-values, before adding any filters for expression or fold-change or otherwise subsetting the data:
      data$FDR = p.adjust(data$pvalues, method="BH")
      or, synonymously,
      data$FDR = p.adjust(data$pvalues, method="fdr")
    • The R package DESeq2 creates a "padj" column using the p.adjust() R function as above. 

  • Bonferroni correction
    • Much stricter (more conservative) than the Benjamini-Hochberg FDR method.
    • Leaves less significant values overall. Drastically reduces false positives (type I error), but increases false negatives (type II error).
    • Sometimes used for DNA methylation data if other quality control steps suggest the data has high inflation (higher risk of false positives).
    • Not typically used for RNA-seq.
    • In R, make a new "bonferroni" column in your complete dataset using the full list of p-values, before adding any filters for expression or fold-change or otherwise subsetting the data:
      data$bonferroni = p.adjust(data$pvalues, method="bonferroni")

Additional reading:

November 16, 2021

How to download raw sequencing data using NCBI GEO accessions

This BiteSize Bio YouTube tutorial is very helpful for understanding RNA-seq depositories and what data is stored at NCBI GEO versus the SRA.

For my walk-through example, I am using our placenta single cell sequencing published in 2020. 

August 25, 2021

How to look up gene synonyms quickly with db2db (and fix the calendar gene issue)

If you have a list of gene symbols or Ensembl IDs and need to identify gene synonyms, try the Database to Database Conversions tool from bioDBnet: https://biodbnet-abcc.ncifcrf.gov/db/db2db.php

This is also a great way to correct calendar gene name conversion errors when opening a csv file in Excel. 

Quick tutorial for db2db

June 23, 2021

RNA isolation tips and RNA integrity numbers (RINs) explained

Step 1: Extract RNA from tissue or plasma or cells.

  • If new to RNA work, read this: "5 Sure-Fire Ways to Screw Up Your RNA extraction" (BiteSizeBio).

  • Store samples properly to preserve RNA
    • "Snap freeze" bacteria, plant tissue, and human tissue by submerging tubes in liquid nitrogen, then store in liquid nitrogen or at -80C. The samples can be ok for years.
    • "Snap freeze" with a dry ice and alcohol bath if no liquid nitrogen is available. Leave the tubes in the bath for a few minutes until sample is frozen solid, then transfer to -80C storage.
    • Immerse delicate human tissue in RNAlater Stabilization Solution (commercial product, patent #US6204375), then store at -80C. Snap freezing isn't enough to preserve RNA in some tissue (Pisarska et al. 2016).
    • Keep samples fully frozen until ready to process. Thawing/re-freezing degrades sample RNA each time you do it.

  • Temperature - keep cold! Except for small RNA isolation at some steps
    • Homogenize samples on ice or colder (some methods require dry ice or liquid nitrogen)
    • After homogenization, RNA extractions are typically done on ice or with ice-cold reagents.
      • Exception: miRNA extractions are at room temperature due to the use of isopropanol, which improves the yield of small RNAs but also salts. After homogenization on ice, miRNA protocols switch to room temperature to prevent too much salt in the final elution.
    • Keep RNA on ice after the RNA extraction protocol's elution step.
      • All RNA, including samples with miRNA
      • "Elution" is when the purified molecule is pulled down from the column and collected in your final tube.
    • Store RNA at -80C (best) or -20C (ok short-term) and avoid too many freeze/thaw cycles (RNA starts to degrade). 
    • Thaw RNA on ice for later experiments (e.g. qRT-PCR) and keep on ice. 
      • Reduce activity of RNases (if any)
      • Reduce autolysis: RNA is less stable than DNA due to the extra 2' OH group which allows RNA to cut itself. 
    • Don't leave RNA at 4C overnight. Store at -20C if you need to store it overnight.
      • It's a balance between the risk of RNA auto-hydrolysis at 4C (which happens even without RNases present) vs the risk of another freeze/thaw cycle degrading RNA.

September 14, 2020

How to download FASTA files from NCBI

FASTA format

FASTA files are text files used to store sequence information. The format is 2 lines of text:

>title line starting with a greater-than sign

sequence with no double line breaks or special characters


FASTA file extensions are usually .fasta or .fa but can also be .txt because, either way, they are just text files. Open them as text files with Notepad. For large sequences, Notepad++ works better (more memory allocation). Word or any other text file reader will work as well.

July 11, 2020

How to create publication quality images (high resolution images)

Journals typically request that images for publication be at 300 dpi resolution for photos (e.g. microscope images), 600 dpi for images, and 1200 dpi for line art. PowerPoint and Excel default settings don't meet these requirements. 

Use these tips to get high resolution images:

March 26, 2020

How to format a research article for publication

Select a target journal (or narrow it down to a few)

Maybe helpful tool: "Elsevier Journal Finder". Only use this tool to get ideas, not to decide where your paper should go. 

Search for related topics yourself on PubMed and Google Scholar. Consider the type of study that you are working on (cell function experiments, mRNA-seq, epigenomics array, clinical charts review, etc). Look up the journal's "about" page, impact factor, and recently published research papers to estimate if it is a good fit for your article. 

Journal specific formatting

Search the journal name and "author guidelines" to find information about section names and expected order, word count limits for the abstract, word limits for the whole manuscript, formatting requirements, figure size limits, figure resolutions and file types accepted, etc. For example, here are some journal author guidelines:

(Impact factors updated 8/20/2025)


If you aren't sure which journal you'll submit to, pick a few journals and read their author guidelines (especially word limits, figure+table limits) and start writing based on the stricter guidelines (lower limits). You can narrow down the journal later.

Microsoft Word formatting

Citation software, continuous line numbering, autocorrect modifications, etc.

January 18, 2020

How to improve PubMed and Google search results with boolean operators

Use boolean searches to make dataset and literature reviews easier and more efficient at:

Example search:
(TP53 OR p53) AND (cancer OR elephants OR "cell division" OR "cell cycle") NOT (mice OR mouse)

This searches for the gene name (TP53) or the protein name (p53), plus at least one word or quoted phrase in the second part. It also excludes searches with the terms "mice" or "mouse".

R programming lesson #2: merging pdf files

Use R package "pdftools" to merge separate pdf into one pdf file. You will never need to use sketchy websites or pay for software ...