Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Use seed for nondeterministic processes vib-singlecell-nf/vsn-pipelin…
Browse files Browse the repository at this point in the history
  • Loading branch information
dweemx committed Feb 14, 2020
1 parent 1abc146 commit 9379696
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
11 changes: 10 additions & 1 deletion bin/dim_reduction/sc_dim_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
)

parser.add_argument(
"-s", "--svd-solver",
"-v", "--svd-solver",
type=str,
action="store",
dest="svd_solver",
Expand Down Expand Up @@ -72,6 +72,15 @@
help="Use the MulticoreTSNE package by D. Ulyanov if it is installed."
)

parser.add_argument(
"-s", "--seed",
type=int,
action="store",
dest="seed",
default=0,
help="Use this integer seed for reproducibility."
)

args = parser.parse_args()

# Define the arguments properly
Expand Down
13 changes: 12 additions & 1 deletion bin/nn/sc_neighborhood_graph.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
help="Use this many PCs. If n_pcs==0 use .X if use_rep is None."
)

parser.add_argument(
"-s", "--seed",
type=int,
action="store",
dest="seed",
default=0,
help="Use this integer seed for reproducibility."
)


args = parser.parse_args()

# Define the arguments properly
Expand All @@ -57,7 +67,8 @@
sc.pp.neighbors(
adata=adata,
n_neighbors=args.n_neighbors,
n_pcs=args.n_pcs
n_pcs=args.n_pcs,
random_state=args.seed
)

# I/O
Expand Down
4 changes: 3 additions & 1 deletion processes/dim_reduction.nf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ process SC__SCANPY__DIM_REDUCTION {
tuple \
val(sampleId), \
path("${sampleId}.SC__SCANPY__DIM_REDUCTION_${method}.${!isParamNull(stashedParams) ? uuid + '.' : ''}${processParams.off}"), \
val(stashedParams)
val(stashedParams), \
val(nComps)

script:
def sampleParams = params.parseConfig(sampleId, params.global, params.sc.scanpy.dim_reduction.get(params.method))
Expand All @@ -110,6 +111,7 @@ process SC__SCANPY__DIM_REDUCTION {
_processParams.setConfigParams(processParams)
"""
${binDir}dim_reduction/sc_dim_reduction.py \
${'--seed ' + (params.global.containsKey('seed') ? params.global.seed: params.seed)} \
--method ${processParams.dimReductionMethod} \
${(processParams.containsKey('svdSolver')) ? '--svd-solver ' + processParams.svdSolver : ''} \
${(processParams.containsKey('nNeighbors')) ? '--n-neighbors ' + processParams.nNeighbors : ''} \
Expand Down
8 changes: 5 additions & 3 deletions processes/neighborhood_graph.nf
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ process SC__SCANPY__NEIGHBORHOOD_GRAPH {
output:
tuple \
val(sampleId), \
path("${sampleId}.SC__SCANPY__NEIGHBORHOOD_GRAPH.${processParams.off}") \
val(stashedParams)
path("${sampleId}.SC__SCANPY__NEIGHBORHOOD_GRAPH.${processParams.off}"), \
val(stashedParams),
val(nComps)

script:
def sampleParams = params.parseConfig(sampleId, params.global, params.sc.scanpy.filter)
Expand All @@ -103,9 +104,10 @@ process SC__SCANPY__NEIGHBORHOOD_GRAPH {
_processParams.setEnv(this)
_processParams.setConfigParams(processParams)
"""
${binDir}cluster/sc_neighborhood_graph.py \
${binDir}nn/sc_neighborhood_graph.py \
$f \
${sampleId}.SC__SCANPY__NEIGHBORHOOD_GRAPH.${processParams.off} \
${'--seed ' + (params.global.containsKey('seed') ? params.global.seed: params.seed)} \
${(processParams.containsKey('nNeighbors')) ? '--n-neighbors ' + processParams.nNeighbors : ''} \
${_processParams.getNCompsAsArgument(nComps)}
"""
Expand Down
2 changes: 1 addition & 1 deletion workflows/cluster_identification.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nextflow.preview.dsl=2
//////////////////////////////////////////////////////
// process imports:

include '../../utils/processes/utils.nf'
include '../../utils/processes/utils.nf' params(params)

// scanpy:
include '../processes/cluster' params(params)
Expand Down

0 comments on commit 9379696

Please sign in to comment.