if err != nil {
return err
}
- if len(cmd.samples[0].pcaComponents) > 0 {
- cmd.pvalue = glmPvalueFunc(cmd.samples, cmd.pcaComponents)
- // Unfortunately, statsmodel/glm lib logs
- // stuff to os.Stdout when it panics on an
- // unsolvable problem. We recover() from the
- // panic in glm.go, but we also need to
- // commandeer os.Stdout to avoid producing
- // large quantities of logs.
- stdoutWas := os.Stdout
- defer func() { os.Stdout = stdoutWas }()
- os.Stdout, err = os.Open(os.DevNull)
- if err != nil {
- return err
- }
- }
} else if *caseControlOnly {
return fmt.Errorf("-case-control-only does not make sense without -samples")
}
cmd.minCoverage = int(math.Ceil(cmd.filter.MinCoverage * float64(len(cmd.cgnames))))
}
+ if len(cmd.samples[0].pcaComponents) > 0 {
+ cmd.pvalue = glmPvalueFunc(cmd.samples, cmd.pcaComponents)
+ // Unfortunately, statsmodel/glm lib logs stuff to
+ // os.Stdout when it panics on an unsolvable
+ // problem. We recover() from the panic in glm.go, but
+ // we also need to commandeer os.Stdout to avoid
+ // producing large quantities of logs.
+ stdoutWas := os.Stdout
+ defer func() { os.Stdout = stdoutWas }()
+ os.Stdout, err = os.Open(os.DevNull)
+ if err != nil {
+ return err
+ }
+ }
+
+ // cgnamemap[name]==true for samples that we are including in
+ // output
+ cgnamemap := map[string]bool{}
+ for _, name := range cmd.cgnames {
+ cgnamemap[name] = true
+ }
+
{
samplesOutFilename := *outputDir + "/samples.csv"
log.Infof("writing sample metadata to %s", samplesOutFilename)
}
if si.isTraining {
tv = "1"
- } else {
+ } else if si.isValidation {
tv = "0"
}
_, err = fmt.Fprintf(f, "%d,%s,%s,%s\n", i, si.id, cc, tv)
if cmd.filter.MaxTag >= 0 && cg.StartTag > tagID(cmd.filter.MaxTag) {
return errSkip
}
- if !matchGenome.MatchString(cg.Name) {
+ if !cgnamemap[cg.Name] {
continue
}
// pad to full slice size
return err
}
defer f.Close()
+ pcaLabels := ""
+ for i := 0; i < outcols; i++ {
+ pcaLabels += fmt.Sprintf(",PCA%d", i)
+ }
+ _, err = fmt.Fprintf(f, "Index,SampleID,CaseControl,TrainingValidation%s\n", pcaLabels)
+ if err != nil {
+ return err
+ }
for i, si := range cmd.samples {
var cc, tv string
if si.isCase {
}
if si.isTraining {
tv = "1"
- } else {
+ } else if si.isValidation {
tv = "0"
}
var pcavals string