HCBravoLab / metagenomeSeq

Statistical analysis for sparse high-throughput sequencing
64 stars 20 forks source link

Error while CSS normalization when setting useCSSoffset = TRUE #62

Open misazaa opened 5 years ago

misazaa commented 5 years ago

Hi,

I want to normalize my OTU table with CSS normalization so I can calculate beta diversity. I tried the code on the package documentation, but when I set useCSSoffset=TRUE, I get the error:

Error in if (any(pos)) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In pt(-abs(out$t), df = df.total) : NaNs produced 2: In pt(tstat, df = MaxDF, lower.tail = FALSE) : NaNs produced

What I understand is that in order to do the normalization without inputing my own parameters and using the default, useCSSoffset needs to be true.

I don't know why am I getting this error, any hints would be very much appreciated.

This is the code I¡m running biomfile <- read_biom("otu_table.biom") otu_table <- as.data.frame(as.matrix(biom_data(biomfile))) taxa <- observation_metadata(biomfile) mapfile = loadPhenoData("mapping_file.txt", tran = TRUE) phenotypeData = AnnotatedDataFrame(mapfile) OTUdata = AnnotatedDataFrame(taxa) obj = newMRexperiment(otu_table,phenoData=phenotypeData,featureData=OTUdata)

Normalization

Calculate normalization factors

p = cumNormStat(obj, pFlag = TRUE, main = "Trimmed obj")

calculate the scaling factors

obj = cumNorm(obj, p = p)

Zero-inflated Gaussian mixture model

treatmentstatus = pData(obj)$Organ settings = zigControl(tol=1e-10, maxit = 20, verbose = TRUE) mod = model.matrix(~treatmentstatus) colnames(mod) = levels(treatmentstatus) res = fitZig(obj = obj, mod = mod, useCSSoffset = TRUE, control = settings)

jnpaulson commented 5 years ago

You probably have some very lowly abundant otus (perhaps all zero). Have you tried a filtering process? On Sat, Jan 5, 2019 at 6:24 AM misazaa notifications@github.com wrote:

Hi,

I want to normalize my OTU table with CSS normalization so I can calculate beta diversity. I tried the code on the package documentation, but when I set useCSSoffset=TRUE, I get the error:

Error in if (any(pos)) { : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In pt(-abs(out$t), df = df.total) : NaNs produced 2: In pt(tstat, df = MaxDF, lower.tail = FALSE) : NaNs produced

What I understand is that in order to do the normalization without inputing my own parameters and using the default, useCSSoffset needs to be true.

I don't know why am I getting this error, any hints would be very much appreciated.

This is the code I¡m running biomfile <- read_biom("otu_table.biom") otu_table <- as.data.frame(as.matrix(biom_data(biomfile))) taxa <- observation_metadata(biomfile) mapfile = loadPhenoData("mapping_file.txt", tran = TRUE) phenotypeData = AnnotatedDataFrame(mapfile) OTUdata = AnnotatedDataFrame(taxa) obj = newMRexperiment(otu_table,phenoData=phenotypeData,featureData=OTUdata) Normalization Calculate normalization factors

p = cumNormStat(obj, pFlag = TRUE, main = "Trimmed obj") calculate the scaling factors

obj = cumNorm(obj, p = p) Zero-inflated Gaussian mixture model

treatmentstatus = pData(obj)$Organ settings = zigControl(tol=1e-10, maxit = 20, verbose = TRUE) mod = model.matrix(~treatmentstatus) colnames(mod) = levels(treatmentstatus) res = fitZig(obj = obj, mod = mod, useCSSoffset = TRUE, control = settings)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HCBravoLab/metagenomeSeq/issues/62, or mute the thread https://github.com/notifications/unsubscribe-auth/AC5hgyRICe0GJQYEBBQ8CYveNkgtvMH_ks5vACkEgaJpZM4ZvH-Z .

misazaa commented 5 years ago

I do have very low abundant OTUs, not all zero, but with abundances of 1, 2, 3 etc throughout all the samples. I didn't try a filtering process because they are actually ASVs outputted from DADA2, so I figured even ASVs with low abundances are true sequences.

I tried removing ASVs with abundances of 1, 2 and 3, (in all the samples) after @jnpaulson comment but the normalization still doesn't work with useCSSoffset = TRUE. So I don't know of there is a problem with my OTU table or my mapping file. I attached them so that maybe I can be guided towards what should I change.

Thanks in advance!

mapping_file.txt otu_table.txt