Normalization data: Error in .local(object, ..., value): all(!is.na(value)) is not TRUE

Hello everyone, does anyone of you know what this error means? (Error in .local(object, ..., value): all(!is.na(value)) is not TRUE)
I had already done this analysis many times and I don't know what is happening now.

library(readxl)
Family <- read_excel("~/RSTUDIO/Datos_cianobacterias/ciano_otu_family_rdp.xlsx")



#NORMALIZATION OF RAW READ TABLE LOG2
#OTUS en filas, columnas son las muestras, es al reves que para el resto de pasos
data<- Family

replicates <- as.data.frame(colnames(data)[-1])
colnames(replicates) <- "replicates"
attach(Family)
rwnames <- OTU
data <- as.matrix(data[,-1])
rownames(data) <- rwnames
data[is.na(data)] <- 0
library(DESeq2)
#> Loading required package: S4Vectors
#> Loading required package: stats4
#> Loading required package: BiocGenerics
#> Loading required package: parallel
#> 
#> Attaching package: 'BiocGenerics'
#> The following objects are masked from 'package:parallel':
#> 
#>     clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
#>     clusterExport, clusterMap, parApply, parCapply, parLapply,
#>     parLapplyLB, parRapply, parSapply, parSapplyLB
#> The following objects are masked from 'package:stats':
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from 'package:base':
#> 
#>     anyDuplicated, append, as.data.frame, basename, cbind,
#>     colMeans, colnames, colSums, dirname, do.call, duplicated,
#>     eval, evalq, Filter, Find, get, grep, grepl, intersect,
#>     is.unsorted, lapply, lengths, Map, mapply, match, mget, order,
#>     paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind,
#>     Reduce, rowMeans, rownames, rowSums, sapply, setdiff, sort,
#>     table, tapply, union, unique, unsplit, which, which.max,
#>     which.min
#> 
#> Attaching package: 'S4Vectors'
#> The following object is masked from 'package:base':
#> 
#>     expand.grid
#> Loading required package: IRanges
#> 
#> Attaching package: 'IRanges'
#> The following object is masked from 'package:grDevices':
#> 
#>     windows
#> Loading required package: GenomicRanges
#> Loading required package: GenomeInfoDb
#> Loading required package: SummarizedExperiment
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> Loading required package: DelayedArray
#> Loading required package: matrixStats
#> 
#> Attaching package: 'matrixStats'
#> The following objects are masked from 'package:Biobase':
#> 
#>     anyMissing, rowMedians
#> Loading required package: BiocParallel
#> 
#> Attaching package: 'DelayedArray'
#> The following objects are masked from 'package:matrixStats':
#> 
#>     colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
#> The following objects are masked from 'package:base':
#> 
#>     aperm, apply
dds <- DESeqDataSetFromMatrix(data, replicates, ~ replicates)
#> converting counts to integer mode
cts <- counts(dds)
geoMeans <- apply(cts, 1, function(row) if (all(row == 0)) 0 else exp(mean(log(row[row != 0]))))
dds <- estimateSizeFactors(dds, geoMeans=geoMeans)
#> Error in .local(object, ..., value): all(!is.na(value)) is not TRUE
norm <- counts(dds, normalized=TRUE)
#> Error in .local(object, ...): first calculate size factors, add normalizationFactors, or set normalized=FALSE
logcounts <- log2( counts(dds, normalized=TRUE) + 1 )# in case you want a log transformed normalized count
#> Error in .local(object, ...): first calculate size factors, add normalizationFactors, or set normalized=FALSE
write.csv(logcounts, file = "~/RSTUDIO/Bacteria-total/bacteria-total-normalizados.csv")
#> Error in is.data.frame(x): objeto 'logcounts' no encontrado

Created on 2020-02-06 by the reprex package (v0.3.0)

Inglés

Quisiste decir:

No puedo pegar mi base de datos en el formato que ustedes lo requieren REDEX, porque me arrojó este error R

I could not paste my database in the format that you require REDEX, because I threw this error R: R code execution error
But this is the image of my data base:

Thank you so much!

It seems like this function requires that you don't have NAs in your data but there are. Although I can't be sure since you are not providing a reprex or at least sample data on a proper format.

1 Like

Excuse me Andres, what does NAs mean?

These are my data, but I analyzed them as in the previous image (Transposed), but that way I could not reprex them.

Family <-tibble::tribble(
           ~index, ~Cyanobacteriaceae, ~Microcystaceae, ~Nostocaceae, ~Phormidiaceae, ~Un.Nostocales, ~Nodosilineaceae, ~Cyanobiaceae,
             "1A",                  1,               0,            0,              0,              0,                1,             1,
             "1B",                  0,               0,            0,              0,              0,                0,             0,
             "1C",                  1,               0,            0,              2,              0,                1,             1,
             "1D",                  0,               0,            1,              0,              0,                1,             0,
             "1E",                  1,               0,            1,              0,              0,                0,             0,
             "1F",                  1,               0,            0,              0,              0,                0,            17,
             "1G",                  1,               0,            0,              0,              0,                0,             2,
             "1H",                  1,             112,            1,            583,              0,                1,             0,
             "2A",                  0,               0,            1,              0,              0,                1,             2,
             "2B",                  1,               0,            0,             35,              0,                1,            29,
             "2C",                  0,               1,            0,              0,              0,                1,             0,
             "2D",                  3,               0,            0,              0,              0,                0,             0,
             "2E",                  0,               0,            1,              0,              0,                0,             0,
             "2F",                  0,               3,            0,              1,              0,                0,             1,
             "2G",                  0,               0,            0,              0,              0,                0,             0,
             "2H",                  0,               0,            9,             18,              0,                0,            17,
             "3A",                  0,               0,           44,             88,              0,                0,             0,
             "3B",                  0,               0,          572,             60,              0,               38,             0,
             "3C",                  0,               0,            0,              0,              0,                0,             0,
             "3D",                  0,               0,            0,              0,              0,                0,             0,
             "3E",                  0,               0,            0,              0,              0,                0,             0,
             "3F",                  0,               0,            0,              0,              0,                0,             0,
             "3G",                  0,               0,            0,              0,              0,                0,             0,
             "3H",                  0,               0,            0,              0,              0,                0,             0,
             "4A",                  0,               0,            0,              0,              0,                0,            27,
             "4B",                  0,               0,            0,              0,              0,                0,            12,
             "4C",                  0,               0,            0,              0,              0,                0,             0,
             "4D",                  0,               0,            0,              0,              0,                0,             0,
             "4E",                  0,               0,            0,              0,              0,                0,             8,
             "4F",                  0,               0,            0,              0,              0,                0,             0,
             "4G",                  0,               0,            0,              0,              0,                0,             8,
             "4H",                  0,               3,           16,             28,              0,                0,            14,
             "5A",                  0,               0,            0,              0,              0,                0,             0,
             "5B",                  0,               0,            0,              0,              0,                0,             0,
             "5C",                  0,               0,            0,              0,              0,                0,             0,
             "5D",                  0,               0,            0,              0,              0,                0,             0,
             "5E",                  0,               0,            0,             17,              0,                0,             0,
             "5F",                  0,               2,            0,              2,              0,                0,            10,
             "5G",                  0,               2,            0,             28,              0,                0,             0,
             "5H",                  0,               0,            0,              0,              0,                0,             0,
             "6A",                  0,               0,           37,              0,              0,                0,             0,
             "6B",                  0,               0,            0,              0,              0,                0,             0,
             "6C",                  0,               0,            0,              0,              0,                0,             0,
             "6D",                  0,               0,            0,              0,              0,                0,             0,
             "6E",                  0,               0,            0,              0,              0,                0,             0,
             "6F",                  0,               0,            0,              0,              0,                0,             4,
             "6G",                  0,               0,            0,              0,              0,                0,             0,
             "6H",                  0,              55,            0,            123,              0,                0,            33,
             "7A",                  0,               0,            0,              0,              0,                0,             0,
             "7B",                  0,               0,            0,              0,              0,                0,             0,
             "7C",                  0,               0,            0,              0,              0,                0,             0,
             "7D",                  0,               0,            0,            128,              0,                0,             2,
             "7E",                  0,               0,            0,              0,              0,                0,             0,
             "7F",                  0,               2,            0,            269,              0,                0,             3,
             "7G",                  0,               0,            0,              0,              0,                0,             5,
             "7H",                  0,               0,            0,              0,              0,                0,             0,
             "8A",                  0,               0,            0,              0,              0,                0,            16,
             "8B",                  0,               0,            0,              0,              0,                0,             3,
             "8C",                  0,               0,            0,             29,              0,                0,             0,
             "8D",                  0,               3,            0,              0,              0,                0,             0,
             "8E",                  0,               0,            0,            102,              0,               16,             2,
             "8F",                  0,               0,            0,              0,              0,                0,             0,
             "8G",                  0,              93,           45,            439,              0,                0,            34,
             "8H",                  0,              35,            0,             24,              0,                0,            17,
             "9A",                  0,               0,            1,              0,              0,                1,             0,
             "9B",                  0,               0,            1,              0,              0,                1,             0,
             "9C",                  0,               0,            0,              0,              1,                0,             0,
             "9D",                  0,               0,            1,              0,              0,                0,             0,
             "9E",                  0,               0,            0,            125,              0,                0,             0,
             "9F",                  0,               2,            8,              0,              0,                0,            31,
             "9G",                  0,               0,            0,              0,              0,                0,            20,
             "9H",                  0,             340,         3670,           2668,             33,               38,             0,
            "10A",                  0,               0,            1,              0,              0,                0,            32,
            "10B",                  0,               0,            0,              1,              0,                0,            14,
            "10C",                  0,               0,            0,              0,              0,                0,             0,
            "10D",                  0,               0,            0,             47,              0,                0,             0,
            "10E",                  0,               1,            0,              0,              0,                0,             0,
            "10F",                  0,               0,            0,              0,              0,                0,             4,
            "10G",                  0,               1,            0,             40,              0,                0,             0,
            "10H",                  0,               1,            0,              0,              1,                0,             0,
            "11A",                  0,               0,            1,              0,              0,                1,             0,
            "11B",                  0,               0,            1,              0,              1,                0,             0,
            "11C",                  0,               0,            1,              0,              0,                0,             0,
            "11D",                  0,               0,            1,              0,              0,                0,             0,
            "11E",                  0,               0,            1,              0,              0,                0,             0,
            "11F",                  0,               0,            0,              1,              0,                0,             0,
            "11G",                  0,               0,            0,              1,              0,                0,             0,
            "11H",                  0,               0,            0,              1,              0,                0,             0,
            "12A",                  0,               0,            0,              0,              0,                0,             0,
            "12B",                  0,               0,            0,              0,              0,                0,             0,
            "12C",                  0,               0,            0,              0,              0,                0,             0,
            "12D",                  0,              20,           77,            145,              0,                0,            22,
            "12E",                  0,               0,            0,              0,              0,                0,             0,
            "12F",                  0,               0,            0,              0,              0,                0,             2,
            "12G",                  0,              68,            2,            296,              0,                0,             0,
            "12H",                  0,             148,          280,            216,              0,                0,            28
           )

Created on 2020-02-06 by the reprex package (v0.3.0)

I already solved it, I saw that in some columns I had no data, then I deleted them and only analyzed those that did, and that's it!

Thanks Andres, you gave me the hint I needed!

I'm glad you manage to solve it. Just for you to be aware of, NA stands for Not Available and is the way R represents missing data.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.