@sjcrh/proteinpaint-server 2.63.3-3 → 2.63.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/utils/burden.R CHANGED
@@ -40,7 +40,7 @@ load(survData)
40
40
  ############################ These are the input values in APP that users can change. Edgar, these should be the same as the APP before, variable names and units. #############
41
41
  ### Input the primary DX.
42
42
  # pr=5
43
- agecut=40 ##### Edgar, This is not an user input paramter, but we input this. This depends on the DX. For example, here for CNS we use 40. For HL DX, it is 55. I will give this value for each DX.
43
+ # agecut=40 ##### Edgar, This is not an user input paramter, but we input this. This depends on the DX. For example, here for CNS we use 40. For HL DX, it is 55. I will give this value for each DX.
44
44
 
45
45
  # # # Input person's values, 18 input X's , plus the input primary DX
46
46
  # sexval=1 #sex, take value 1 for male and 0 for female
@@ -88,6 +88,8 @@ newdata_chc_sampled=newdata_chc_sampled[newdata_chc_sampled$t.endage<=60,]
88
88
 
89
89
  # paste(names(input), input, sep = ":", collapse = ",")
90
90
  pr=input$diaggrp
91
+ # agecut was previously hardcoded to 40 above
92
+ agecut=c('1'=50, '2'=45, '3'=55, '4'=50, '5'=40, '6'=60, '7'=50, '8'=45, '9'=45, '10'=45, '11'=50 )[pr]
91
93
  sexval=input$sex
92
94
  newdata_chc_sampled$sex=input$sex # sexval
93
95
  newdata_chc_sampled$white=input$white # whiteval
@@ -1,110 +0,0 @@
1
- import fs from "fs";
2
- import { spawn } from "child_process";
3
- import { Readable } from "stream";
4
- import path from "path";
5
- import serverconfig from "../src/serverconfig.js";
6
- const api = {
7
- endpoint: "genesetEnrichment",
8
- methods: {
9
- all: {
10
- init,
11
- request: {
12
- typeId: "genesetEnrichmentRequest"
13
- },
14
- response: {
15
- typeId: "genesetEnrichmentResponse"
16
- // will combine this with type checker
17
- //valid: (t) => {}
18
- }
19
- }
20
- }
21
- };
22
- function init({ genomes }) {
23
- return async (req, res) => {
24
- try {
25
- const results = await run_genesetEnrichment_analysis(req.query, genomes);
26
- res.send(results);
27
- } catch (e) {
28
- res.send({ status: "error", error: e.message || e });
29
- }
30
- };
31
- }
32
- async function run_genesetEnrichment_analysis(q, genomes) {
33
- if (!genomes[q.genome].termdbs)
34
- throw "termdb database is not available for " + q.genome;
35
- const genesetenrichment_input = {
36
- genes: q.genes,
37
- fold_change: q.fold_change,
38
- db: genomes[q.genome].termdbs.msigdb.cohort.db.connection.name,
39
- gene_set_group: q.geneSetGroup
40
- };
41
- const gsea_output = await run_gsea(
42
- path.join(serverconfig.binpath, "../python/src", "gsea.py"),
43
- "/" + JSON.stringify(genesetenrichment_input)
44
- // "/" is needed for python to accept the bracket "{" as a bracket
45
- );
46
- let result;
47
- for (const line of gsea_output.split("\n")) {
48
- if (line.startsWith("result: ")) {
49
- result = JSON.parse(line.replace("result: ", ""));
50
- } else {
51
- console.log(line);
52
- }
53
- }
54
- return result;
55
- }
56
- async function run_gsea(path2, data) {
57
- try {
58
- await fs.promises.stat(path2);
59
- } catch (e) {
60
- throw `${path2} does not exist`;
61
- }
62
- return new Promise((resolve, reject) => {
63
- const _stdout = [];
64
- const _stderr = [];
65
- let python_path = "python3";
66
- if (serverconfig.py_path)
67
- python_path = serverconfig.py_path;
68
- const sp = spawn(python_path, [path2]);
69
- if (data) {
70
- try {
71
- const input = data.endsWith("\n") ? data : data + "\n";
72
- Readable.from(input).pipe(sp.stdin);
73
- } catch (e) {
74
- sp.kill();
75
- let errmsg = e;
76
- const stderr = _stderr.join("").trim();
77
- if (stderr)
78
- errmsg += `
79
- python stderr: ${stderr}`;
80
- reject(errmsg);
81
- }
82
- }
83
- sp.stdout.on("data", (data2) => _stdout.push(data2));
84
- sp.stderr.on("data", (data2) => _stderr.push(data2));
85
- sp.on("error", (err) => reject(err));
86
- sp.on("close", (code) => {
87
- const stdout = _stdout.join("").trim();
88
- const stderr = _stderr.join("").trim();
89
- if (code !== 0) {
90
- let errmsg = `python process exited with non-zero status code=${code}`;
91
- if (stdout)
92
- errmsg += `
93
- python stdout: ${stdout}`;
94
- if (stderr)
95
- errmsg += `
96
- python stderr: ${stderr}`;
97
- reject(errmsg);
98
- }
99
- if (stderr) {
100
- const errmsg = `python process emitted standard error
101
- python stderr: ${stderr}`;
102
- reject(errmsg);
103
- }
104
- resolve(stdout);
105
- });
106
- });
107
- }
108
- export {
109
- api
110
- };