josefin-werme / LAVA

51 stars 9 forks source link

Invalid target phenotype specified #74

Closed dqq0404 closed 5 months ago

dqq0404 commented 5 months ago

Hi, I got a error about: "Error: Invalid target phenotype specified: 'trait1'" The log is: "Warning: Negative variance estimate for phenotype(s) 'trait3' in locus...; Dropping these as they cannot be analysed" "Warning: Negative variance estimate for phenotype(s) 'trait2' in locus...; Dropping these as they cannot be analysed" "Warning: Negative variance estimate for phenotype(s) 'trait1' in locus...; Dropping these as they cannot be analysed" "Error: Invalid target phenotype specified: 'trait1'"

The script is:

library(LAVA)

input = process.input(input.info.file = input_info_file,sample.overlap.file = sample_overlap_file,ref.prefix = ".../EUR",phenos = c("trait1","trait2","trait3")) loci = read.loci(".../GRCh37_hg19.locfile") n.loc = nrow(loci)

Set univariate pvalue threshold

univ.p.thresh = 1e-4

Analyse

print(paste("Starting LAVA analysis for",n.loc,"loci")) progress = ceiling(quantile(1:n.loc, seq(.05,1,.05))) # (if you want to print the progress)

u=b=list() for (i in 1:n.loc) { if (i %in% progress) print(paste("..",names(progress[which(progress==i)]))) # (printing progress) locus = process.locus(loci[i,], input) # process locus

    # It is possible that the locus cannot be defined for various reasons (e.g. too few SNPs), so the !is.null(locus) check is necessary before calling the analysis functions.
    if (!is.null(locus)) {
            # extract some general locus info for the output
            loc.info = data.frame(locus = locus$id, chr = locus$chr, start = locus$start, stop = locus$stop, n.snps = locus$n.snps, n.pcs = locus$K)

            # run the univariate and bivariate tests
            loc.out = run.univ.bivar(locus, univ.thresh = univ.p.thresh, target = "trait1")
            u[[i]] = cbind(loc.info, loc.out$univ)
            if(!is.null(loc.out$bivar)) b[[i]] = cbind(loc.info, loc.out$bivar)
    }

}

save the output

write.table(do.call(rbind,u), paste0(out.fname,".univ.lava"), row.names=F,quote=F,col.names=T) write.table(do.call(rbind,b), paste0(out.fname,".bivar.lava"), row.names=F,quote=F,col.names=T)

print(paste0("Done! Analysis output written to ",out.fname,".*.lava"))

I use the target parameter and this error happened to me. How to fix it?

dqq0404 commented 5 months ago

Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 1, 0 Calls: cbind -> cbind -> data.frame Execution halted

dqq0404 commented 5 months ago

Hi, I solved this problem by using a loop to analyze trait1 with other traits.