Add -log10(pvalue) row to onehot-columns.npy output from slicenumpy.
authorTom Clegg <tom@curii.com>
Fri, 29 Apr 2022 18:57:44 +0000 (14:57 -0400)
committerTom Clegg <tom@curii.com>
Fri, 29 Apr 2022 18:57:44 +0000 (14:57 -0400)
closes #19014

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

slice_test.go
slicenumpy.go

index 74e0e34519948b55ec03d658b284411273eef55f..8af51614ae430493faaa588509097b056bbdc63d 100644 (file)
@@ -352,6 +352,26 @@ pipeline1dup/input2        0
                                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
                        })
                }
+
+               f, err = os.Open(npydir + "/onehot-columns.npy")
+               c.Assert(err, check.IsNil)
+               defer f.Close()
+               npy, err = gonpy.NewReader(f)
+               c.Assert(err, check.IsNil)
+               c.Check(npy.Shape, check.DeepEquals, []int{8, 5})
+               onehotcols, err := npy.GetInt32()
+               if c.Check(err, check.IsNil) {
+                       for r := 0; r < npy.Shape[0]; r++ {
+                               c.Logf("%v", onehotcols[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
+                       }
+                       c.Check(onehotcols, check.DeepEquals, []int32{
+                               0, 0, 1, 4, 4, 4, 6, 6,
+                               2, 3, 2, 2, 3, 4, 2, 3,
+                               0, 1, 0, 0, 0, 0, 0, 0,
+                               157299, 157299, 157299, 157299, 157299, 157299, 157299, 157299,
+                               803273, 803273, 803273, 803273, 803273, 803273, 803273, 803273,
+                       })
+               }
        }
 }
 
index a2e03f494462a94da2233899ea2488ef6c4c5087..db4b0d367b6210ca6ec1f802b7889693f5d45047 100644 (file)
@@ -1001,7 +1001,7 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                        return 1
                }
                fnm = fmt.Sprintf("%s/onehot-columns.npy", *outputDir)
-               err = writeNumpyInt32(fnm, onehotXref2int32(xrefs), 4, len(xrefs))
+               err = writeNumpyInt32(fnm, onehotXref2int32(xrefs), 5, len(xrefs))
                if err != nil {
                        return 1
                }
@@ -1355,7 +1355,7 @@ func bool2int8(in []bool) []int8 {
 // P-value row contains 1000000x actual p-value.
 func onehotXref2int32(xrefs []onehotXref) []int32 {
        xcols := len(xrefs)
-       xdata := make([]int32, 4*xcols)
+       xdata := make([]int32, 5*xcols)
        for i, xref := range xrefs {
                xdata[i] = int32(xref.tag)
                xdata[xcols+i] = int32(xref.variant)
@@ -1363,6 +1363,7 @@ func onehotXref2int32(xrefs []onehotXref) []int32 {
                        xdata[xcols*2+i] = 1
                }
                xdata[xcols*3+i] = int32(xref.pvalue * 1000000)
+               xdata[xcols*4+i] = int32(-math.Log10(xref.pvalue) * 1000000)
        }
        return xdata
 }