Count normalization with DESeq2 - Answer key

Exercise 1

Suppose we have sample names matching in the counts matrix and metadata file, but they are in different order. Write the line(s) of code to create a new matrix with columns re-ordered such that they are identical to the row names of the metadata.

There are multiple ways to do this. For example:

idx <- match(rownames(meta), colnames(data))
data_reordered <- data[, idx]

OR

data_reordered <- data[, match(rownames(meta), colnames(data))]

OR

txi$counts <- txi$counts[, match(rownames(meta), colnames(txi$counts))]