Skip to content

Commit

Permalink
Tables
Browse files Browse the repository at this point in the history
  • Loading branch information
lindemann09 committed Aug 24, 2023
1 parent fe4355b commit 78d0df6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClusterPermutationTests"
uuid = "e3bc594e-7e39-4b61-be5a-4b8b3e7ff14e"
authors = ["Oliver Lindemann"]
version = "0.2.6"
version = "0.2.7-DEV"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Expand All @@ -11,6 +11,7 @@ ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsAPI = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

Expand Down
1 change: 1 addition & 0 deletions src/ClusterPermutationTests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ClusterPermutationTests

using DataAPI
using Tables
using TypedTables
using StatsModels
using Random
Expand Down
2 changes: 1 addition & 1 deletion src/clusterpermutationtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function cluster_table(x::ClusterPermutationTest)::Table
return Table(id = 1:length(cl_ranges),
from = [c.start for c in cl_ranges],
to = [c.stop for c in cl_ranges],
length = [c.stop - c.start + 1 for c in cl_ranges],
size = [c.stop - c.start + 1 for c in cl_ranges],
min = [minimum(stats[c]) for c in cl_ranges],
max = [maximum(stats[c]) for c in cl_ranges],
p = p,
Expand Down
12 changes: 8 additions & 4 deletions src/cpdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ function CPData(; data_mtx::AbstractMatrix{<:Real},
unit_obs::OptSymbolOString,
kwargs...)

design_tbl = Table(design)
# check nrows
size(data_mtx, 1) == length(design_tbl) || throw(
Tables.istable(design) || throw(ArgumentError(
"design is not a table, but $(typeof(design)).",))

design_tbl = TypedTables.Table(design)
nrows = length(design_tbl)

size(data_mtx, 1) == nrows|| throw(
DimensionMismatch(
"Matrix and design table must have the same number of rows!"),
)
Expand All @@ -34,7 +38,7 @@ function CPData(; data_mtx::AbstractMatrix{<:Real},
end

# select subset with specified conditions
ids = ones(Bool, length(design_tbl))
ids = ones(Bool, nrows)
for (values, var) in zip(values(kwargs), ivs)
if !(values isa DataAPI.All) # select all columns
ids = ids .& has_values(design_tbl, var, values)
Expand Down

0 comments on commit 78d0df6

Please sign in to comment.