DESeq2 normalization
1
0
Entering edit mode
2.2 years ago
Rob ▴ 170

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

metadata <- read.table("Clinical.txt", header = TRUE, row.names = 1, stringsAsFactors = TRUE) #metadata is a table of samples' information


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

BiocManager::install("SummarizedExperiment")

se <- SummarizedExperiment(rawdata)
colData(se) <- DataFrame(pData(metadata))

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 • 1.6k views
ADD COMMENT
0
Entering edit mode

I deleted the other post you opened for this as it's already being addressed here. Please stop spamming the forum with multiple threads addressing the same problem, or your account will be suspended.

ADD REPLY
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

I'll reopen your other question.

ADD REPLY
3
Entering edit mode
2.2 years ago
LauferVA 4.2k

try this, rob:

Read in your raw data

rawdata <- read.csv("data.csv", header = TRUE,row.names = 1, stringsAsFactors = FALSE, check.names = F) #rawdata is a count matrix
metadata <- read.table("Clinical.txt", header = TRUE, row.names = 1, stringsAsFactors = TRUE) #metadata is a table of samples' information

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
colData(se) <- DataFrame(pData(metadata))

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 ) )
ADD COMMENT
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?

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

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

se <- SummarizedExperiment(exprs(rawdata)) ## how you like me now
colData(se) <- DataFrame(pData(metadata))

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
ADD REPLY
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

ADD REPLY

Login before adding your answer.

Traffic: 2311 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6