DESeq2 normalization
1
0
Entering edit mode
4 months ago
Rob ▴ 120

Hi friends I am using this code to normalize my data.

is this code complete for normalizing or the last 3 lines are not needed?

this code:

rawdata <- read.csv("data.csv",
header = TRUE,row.names = 1, stringsAsFactors = FALSE,
check.names = F) #rawdata is a count matrix

library(Biobase)
library(GenomicRanges)
library(tibble)
library(dplyr)
install.packages("BiocManager")

BiocManager::install("SummarizedExperiment")

se <- SummarizedExperiment(rawdata)

library(DESeq2)
dds <- DESeqDataSet( se, design = ~ 1 )

#lat 3 lines: are these necessary for the normalization pf
dds <- estimateSizeFactors( dds )
logcounts <- log2( counts(dds, normalized=TRUE) + 1 )
pc <- prcomp( t( logcounts ) )

RNA-Seq • 692 views
0
Entering edit mode

0
Entering edit mode

Rob I apologize, I did not see this comment in the answer:

# I recommend posting this as a separate question if you really cannot figure it out after reading a lot


3
Entering edit mode
4 months ago
Vincent Laufer ★ 1.8k

try this, rob:

rawdata <- read.csv("data.csv", header = TRUE,row.names = 1, stringsAsFactors = FALSE, check.names = F) #rawdata is a count matrix


# install the packages your heart desires

if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")

BiocManager::install("SummarizedExperiment")

# Now, load all packages, ** including those just installed **
library(Biobase)
library(GenomicRanges)
library(tibble)
library(dplyr)
library(DESeq2)
library(SummarizedExperiment)   # <-- very likely what you were missing.


# Try me again:

se <- SummarizedExperiment(exprs(rawdata)) ## how you like me now

dds <- DESeqDataSet( se, design = ~ 1 )

# I recommend posting this as a separate question if you really cannot figure it out after reading a lot
dds <- estimateSizeFactors( dds )
logcounts <- log2( counts(dds, normalized=TRUE) + 1 )
pc <- prcomp( t( logcounts ) )

0
Entering edit mode

Thanks that was the problem. I have another problem now in this part:

library(DESeq2)
dds <- DESeqDataSet( se, design = ~ 1 )

error is: renaming the first element in assays to 'counts'
Error in DESeqDataSet(se, design = ~1) :
counts matrix should be numeric, currently it has mode: list


Can you help me with this please?

0
Entering edit mode
dds <- as(se, "DESeqDataSet")

0
Entering edit mode

thanks this works but in the remaining I get error again.

se <- SummarizedExperiment(exprs(rawdata)) ## how you like me now

dds <- as(se, "DESeqDataSet") ##this works

# I recommend posting this as a separate question if you really cannot figure it out after reading a lot
dds <- estimateSizeFactors( dds ) ##error here
logcounts <- log2( counts(dds, normalized=TRUE) + 1 )
pc <- prcomp( t( logcounts ) )

Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'rowMeans': invalid 'dimnames' given for data frame

0
Entering edit mode

At this point, I would consider taking a laptop with the computer to an organization with data scientists. for instance, if you have an affiliation with a university, perhaps some on-campus weekly tech help thing.

The reason is, to really help you here, at this point Id have to see all of the objects you've made. that's hard to do over the internet but comparatively easy in person

Good luck man