Skip to content

Commit

Permalink
Add block contracts.
Browse files Browse the repository at this point in the history
  • Loading branch information
orenbenkiki committed Aug 29, 2024
1 parent f2b5116 commit 309442c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 0 additions & 2 deletions deps/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ detect_problems = EarlyFilteredLogger(global_logger()) do log_args
end
global_logger(detect_problems)

using JET

import Pkg
Pkg.activate(".")

Expand Down
45 changes: 45 additions & 0 deletions src/contracts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ export block_axis
export block_block_distance_matrix
export block_block_is_in_environment_matrix
export block_block_is_in_neighborhood_matrix
export block_total_UMIs_vector
export cell_axis
export gene_axis
export gene_block_fraction_matrix
export gene_block_is_local_predictive_factor_matrix
export gene_block_total_UMIs_matrix
export gene_divergence_vector
export gene_factor_priority_vector
export gene_is_forbidden_factor_vector
Expand Down Expand Up @@ -210,6 +213,20 @@ function metacell_total_UMIs_vector(expectation::ContractExpectation)::Pair{Vect
)
end

"""
function block_total_UMIs_vector(expectation::ContractExpectation)::Pair{VectorKey, DataSpecification}
The total number of UMIs used to estimate the fraction of all the genes in each block. This is used to estimate
the robustness of the estimates.
"""
function block_total_UMIs_vector(expectation::ContractExpectation)::Pair{VectorKey, DataSpecification}
return ("block", "total_UMIs") => (
expectation,
StorageUnsigned,
"The total number of UMIs used to estimate the fraction of all the genes in each block.",
)
end

"""
function metacell_type_vector(expectation::ContractExpectation)::Pair{VectorKey, DataSpecification}
Expand Down Expand Up @@ -265,6 +282,22 @@ function gene_metacell_total_UMIs_matrix(expectation::ContractExpectation)::Pair
)
end

"""
function gene_block_total_UMIs_matrix(expectation::ContractExpectation)::Pair{MatrixKey, DataSpecification}
The total number of UMIs used to estimate the fraction of each gene in each block. This is used to estimate the
robustness of the estimate. When computing fold factors, we require the total number of UMIs (from both compared
estimates) to be some minimum, and possibly adjust the fold factor according to some confidence level (assuming a
multinomial sampling distribution).
"""
function gene_block_total_UMIs_matrix(expectation::ContractExpectation)::Pair{MatrixKey, DataSpecification}
return ("gene", "block", "total_UMIs") => (
expectation,
StorageUnsigned,
"The total number of UMIs used to estimate the fraction of each gene in each block.",
)
end

"""
function block_block_distance_matrix(expectation::ContractExpectation)::Pair{MatrixKey, DataSpecification}
Expand Down Expand Up @@ -316,4 +349,16 @@ function gene_block_is_local_predictive_factor_matrix(
(expectation, Bool, "A mask of the predictive factors in each block.")
end

"""
function gene_block_fraction_matrix(expectation::ContractExpectation)::Pair{MatrixKey, DataSpecification}
The estimated fraction of the UMIs of each gene in each block. This assumes the metacells in each block are samples of
the "same" biological state, based on the fact that all these metacells have very similar expression levels for all
the global predictive transcription factors.
"""
function gene_block_fraction_matrix(expectation::ContractExpectation)::Pair{MatrixKey, DataSpecification}
return ("gene", "block", "fraction") =>
(expectation, StorageFloat, "The estimated fraction of the UMIs of each gene in each block.")
end

end # module

0 comments on commit 309442c

Please sign in to comment.