Error in -delete: invalid argument to unary operator
0
0
Entering edit mode
4.2 years ago

hello and thank you in advance, to be brief, im doing a DE analysis in R, and first i want to delete the rows with 0 or N/A values. So im performing my script but at the end it sends me an error...here we go:

countData <- read.table("countData.txt", header = TRUE, dec = ".", sep = "\t", row.names = "GeneID")
colData <- read.table("colData.txt", header = TRUE, sep = "\t")
head(colData)

dds <- DESeqDataSetFromMatrix(countData = countData,
                              colData = colData,
                              design = ~treatment)

dds <- estimateSizeFactors(dds)
idx <- rowSums( counts(dds, normalized=TRUE) >= 2 ) >= 8 
dds <- dds[idx,]

dds <- DESeq(dds)
dds

normalized_counts <- counts(dds, normalized=TRUE)
View(normalized_counts)
write.table(as.data.frame(normalized_counts), file = "Count_DEseqNormCount.txt", sep = "\t", dec = ".")

y <- read.table("Count_DEseqNormCount.txt", dec = ".", sep = "\t", header = TRUE, row.names = 1)
names(y)
delete <- NULL


for (row in 1:nrow(y)) {

  flag1 <- FALSE
  flag2 <- FALSE


  if((y[row,1] == 0 && y[row,2] == 0 && y[row,3] == 0 && y[row,4] == 0 && y[row,5] == 0 && y[row,6] == 0) || (y[row,1] >= 1 && y[row,2] >= 1 && y[row,3] >= 1 && y[row,4] >= 1 && y[row,5] >= 1 && y[row,6] >= 1)) {
    flag1 <- TRUE
  } 
  if((y[row,7] == 0 && y[row,8] == 0 && y[row,9] == 0 && y[row,10] == 0 && y[row,11] == 0 && y[row,12] == 0) || (y[row,7] >= 1 && y[row,8] >= 1 && y[row,9] >= 1 && y[row,10] >= 1 && y[row,11] >= 1 && y[row,12] >= 1)) {
    flag2 <- TRUE
  } 

  if (flag1 == FALSE || flag2 == FALSE){
    delete <-c(delete, row)
  }
}

Until here, everything goes OK, but when i type this

y <- y[-delete,]

it says

Error in -delete : argumento no vĂ¡lido para un operador unitario

watching for a translation i think the error is this

Error in -delete : invalid argument to unary operator*

Would be very happy if you could help me, im really new in R and RNASeq. Thank you so much

RNA-Seq R • 14k views
ADD COMMENT
0
Entering edit mode

What is the content of delete? Are you sure you want && instead of &? What is this filtering going to do, I am sure there is a shorter way of expressing this query.

ADD REPLY
0
Entering edit mode

As suggested there are better ways of "filtering", reconsider using &, | instead of &&, I, read about rowSums, colSums.

If you are trying to negate, TRUE to FALSE, FALSE to TRUE, then we need: y <- y[ !delete, ]

ADD REPLY

Login before adding your answer.

Traffic: 1469 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