Skip to content

Commit

Permalink
filter for outliers
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Davydov committed Feb 14, 2025
1 parent 606e9ae commit 0ed8526
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/smooth-rockets-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@platforma-open/milaboratories.repertoire-diversity.workflow': minor
'@platforma-open/milaboratories.repertoire-diversity.model': minor
---

Outliers removed from table and plots if option "Drop outliers" is on
3 changes: 2 additions & 1 deletion model/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export const model = BlockModel.create()
.getData()
.entries.map((v) => v.obj)
.filter(isPColumn)
.filter((column) => valueTypes.find((valueType) => valueType === column.spec.valueType));
.filter((column) => valueTypes.find((valueType) => valueType === column.spec.valueType))
.filter((column) => column.spec.name !== "Sample");

return ctx.createPFrame([...pCols, ...upstream]);
})
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ catalog:
'@milaboratories/software-pframes-conv': ^2.1.8
'@platforma-open/milaboratories.software-small-binaries': ^1.15.7
'@platforma-open/milaboratories.software-mixcr': 4.7.0-137-develop
'@platforma-open/milaboratories.software-ptransform': ^1.2.0

'@platforma-sdk/test': ^1.22.22

Expand Down
1 change: 1 addition & 0 deletions workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@milaboratories/software-pframes-conv": "catalog:",
"@platforma-open/milaboratories.software-small-binaries": "catalog:",
"@platforma-open/milaboratories.software-mixcr": "catalog:",
"@platforma-open/milaboratories.software-ptransform": "catalog:",
"vitest": "catalog:"
}
}
36 changes: 36 additions & 0 deletions workflow/src/filterTables.lib.tengo
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ll := import("@platforma-sdk/workflow-tengo:ll")
exec := import("@platforma-sdk/workflow-tengo:exec")
assets := import("@platforma-sdk/workflow-tengo:assets")
json := import("json")
paggregateSw := assets.importSoftware("@platforma-open/milaboratories.software-ptransform:main")

//// aggregating by-nodes output to make it uniquely addressable by it's native key
filterOutliers := func(inputTsv) {
filterWorkflow := { steps: [
{
type: "filter",
predicate: {
type: "gt",
value: 0,
column: "Observed diversity"
}
}
]
}


filterCmd := exec.builder().
printErrStreamToStdout().
software(paggregateSw).
arg("--workflow").arg("wf.json").
writeFile("wf.json", json.encode(filterWorkflow)).
arg("input.tsv").addFile("input.tsv", inputTsv).
arg("output.tsv").saveFile("output.tsv").
run()

return filterCmd.getFile("output.tsv")
}

export ll.toStrict({
filterOutliers: filterOutliers
})
5 changes: 4 additions & 1 deletion workflow/src/importTsv.tpl.tengo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ json := import("json")

self.defineOutputs("pf")

filterTables := import(":filterTables")

tsvImportParams := {
"axes": [
{
Expand Down Expand Up @@ -58,8 +60,9 @@ self.body(func(args) {

tsvMap := pColumn.resourceMapBuilder(/* key length*/ 1 )
for fileName, file in args.tsv {
filteredFile := filterTables.filterOutliers(file)
chain := fileName[FILE_NAME_PREFIX_LEN:(len(fileName) - FILE_NAME_SUFFIX_LEN)]
tsvMap.add([chain], file)
tsvMap.add([chain], filteredFile)
}
tsvMap = tsvMap.build()

Expand Down

0 comments on commit 0ed8526

Please sign in to comment.