This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Order of operations in RNAseq analysis

Hi all,

I have some RNAseq data and I would like to take the results forward to build a network based on expression correlation (wgcna or similar).

I have several steps that I need to carry out:

  • normalise data
  • transform data
  • subset data (not everything in the dataset is useful for the intended outcome so I need to extract only the useful samples)
  • remove a known batch effect (I know I can model this for differential expression, but for building a network I think I need to remove it - correct me if I am wrong)

I am using DESeq2 for normalisation and transforming using the variance stabilising transform from the same package (as recommend in the wgcna manual).

I have noticed that the outputs of my exploratory analyses change depending on the order in which I carry out these steps, particularly PCAs. In most cases, the gross patterns in the data remain intact, but in some cases this is not true. My question is, what is the correct order in which to carry out these steps and why?

Currently, I am loading all of the available samples, normalising, transforming the normalised counts, removing the batch effect from the transformed data, then extracting the samples of interest. General discussion about the order in which these processes should be carried out is welcome, but specifically:

  1. Would it be more sensible to extract the samples I am interested in first, and then run the downstream steps only on the samples I am interested in? I imagine this would affect the output as the geometric mean across the samples would change.
  2. I am currently removing the batch effect from the vst-transformed data. Would I be better to remove the batch effect first from the normalised counts and then transform the batch-corrected data?

Thanks for your help

rna-seq deseq2 wgcna

1 answer

Thanks for your responses. Your suggestion to include the batch in the design formula is what I usually do for differential expression. I had been led to believe that I had to remove it rather than model it for wgcna, but thinking about it, as long as I can't see it in the PCA it probably doesn't matter how I do it so I'll give that approach a shot as it makes a lot more sense to me.

Just for interest, I think I am going to remove the samples I don't want at the beginning. These are samples that were prepared using a different protocol which the person who did the lab work thinks didn't work correctly. I included them in my preliminary exploratory analysis to see if they were useful, but they obviously aren't, so I think I'll just get rid of them to avoid confusing everything else.

Yes, one should obviously be conservative and assume that there may be no batch effect. Each study is different, of course. I find, in conversations, that many people overly worry about batch adjustment to the point where they may inadvertently do too much adjustment and end up bringing in more bias than they had. A good study design obviously safeguards against having these issues in the first place.

If it's shown that some samples have failed for whatever reason, then it's also perfectly reasonable to exclude them from the outside.

Also, as you can see, technically you were not incorrect in your initial approach. there are various ways of / points at which batch can be dealt with.

Yeah, I was assuming there wasn't a "correct" answer, but I was concerned because the way samples clustered in the exploratory analysis was changing depending on the order I did things in. Input from outside is useful because I was getting to the point of over thinking and confusing myself so thanks for your help.

Your point about over-correcting for batch effects is noted - thanks.

Indeed, and I edited my original answer after having had a brief discussion with other moderators, including Devon and Venu.

Great, thanks for coming back to update us, crouch.k.

Log in to answer this question.