scintegral.classifier module¶
-
scintegral.classifier.classify_cells(expr_mat, cov_mat, size_factor, marker_onehot, device=device(type='cpu'), e_converge=0.0001, lr=0.05, n_itr_max=1000, prior_mean=2, prior_width=0.05, disp_init=2)[source]¶ The cell-type classifier.
- Parameters
expr_mat – An n (number of cells) x g (number of genes) matrix that contains the raw expression counts.
cov_mat – An n x p (number of batches) matrix that contains the batch membership of samples.
size_factor – An n vector of size factors (or any offset variable replacing the size factor).
marker_onehot – A g x t (number of cell-types) matrix containing marker information for each cell-type.
device – A device used in computation (default: cpu).
e_converge – A real number used to determine convergence (default:1e-4).
lr – A real number used as the initial learning-rate (default:0.05).
n_itr_max – The maximum number of iterations in the likielihood optimization step (default:1000).
prior_mean – The threshold parameter for initialization (default:2).
prior_with – The width parameter for initialization (default:0.05).
disp_init – The initial dispersion parameter of the negative binomial likelihood (default:1.5).
- Returns list
A list of assigned cell-type labels.
- Returns class
A torch module object containing the fitted parameters.
-
scintegral.classifier.classify_cells_internal(expr_mat, cov_mat, size_factor, n_type, marker_onehot, device, e_converge, lr, n_itr_max, prior_mean, prior_width, disp_init)[source]¶
-
scintegral.classifier.posterior_probs(delta, beta, phi, expr_mat, cov_mat, size_factor, marker_onehot)[source]¶
-
class
scintegral.classifier.scintegral_loss[source]¶ Bases:
torch.autograd.function.Function-
static
backward(ctx, grad_output)[source]¶ Defines a formula for differentiating the operation.
This function is to be overridden by all subclasses.
It must accept a context
ctxas the first argument, followed by as many outputs didforward()return, and it should return as many tensors, as there were inputs toforward(). Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_gradas a tuple of booleans representing whether each input needs gradient. E.g.,backward()will havectx.needs_input_grad[0] = Trueif the first input toforward()needs gradient computated w.r.t. the output.
-
static
forward(ctx, delta, beta, phi, expr_mat, cov_mat, size_factor, marker_onehot)[source]¶ Performs the operation.
This function is to be overridden by all subclasses.
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
The context can be used to store tensors that can be then retrieved during the backward pass.
-
static
-
class
scintegral.classifier.scintegral_loss_nograd[source]¶ Bases:
torch.autograd.function.Function-
static
forward(ctx, delta, beta, phi, expr_mat, cov_mat, size_factor, marker_onehot)[source]¶ Performs the operation.
This function is to be overridden by all subclasses.
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
The context can be used to store tensors that can be then retrieved during the backward pass.
-
static
-
class
scintegral.classifier.scintegral_model(expr_mat, cov_mat, size_factor, n_type, marker_onehot, prior_mean, prior_width, disp_init)[source]¶ Bases:
torch.nn.modules.module.Module-
forward(only_loss=False)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-
training: bool¶
-