Skip to content

Commit

Permalink
added function description for subset functionss
Browse files Browse the repository at this point in the history
  • Loading branch information
GregFa committed Aug 23, 2024
1 parent af3195d commit 121276b
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions src/utils/wrangling_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Create a subset of a genetic map (`Gmap`) based on specified markers.
* `gmap_selection`: A genetic map from which a subset will be created.
It is assumed that `Gmap` is a custom type or struct representing genetic maps,
which might contain fields such as chromosome (Chr), marker (Locus), and position (Pos).
* `subset_selection`: A list of marker or sample names to select, or an
* `subset_selection`: A list of marker names to select, or an
`InvertedIndex` for deselection.
# Returns
Expand Down Expand Up @@ -162,6 +162,25 @@ function subset_gmap(
end


"""
subset_pheno(
pheno_selection::Pheno,
subset_selection::Union{Vector{String}, InvertedIndex{Vector{String}}}
) -> Pheno
Filter and return a subset of a phenotype data structure based on specified criteria.
# Arguments
* `pheno_selection`: A `Pheno` object containing phenotype data.
* `subset_selection`: This argument can either be a vector of strings specifying
the sample id to retain, or an `InvertedIndex` of a vector of strings
specifying the sample id to exclude.
# Returns
* A new `Pheno` object containing only the selected subset of traits and
corresponding samples.
"""
function subset_pheno(

Check warning on line 184 in src/utils/wrangling_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/wrangling_utils.jl#L184

Added line #L184 was not covered by tests
pheno_selection::Pheno,
subset_selection::Union{Vector{String}, InvertedIndex{Vector{String}}}
Expand Down Expand Up @@ -190,6 +209,23 @@ function subset_pheno(
end


"""
subset_isXchar(isXchar_selection::IsXChar, subset_selection::Union{Vector{String}, InvertedIndex{Vector{String}}}) -> IsFemale
Create a subset of an `IsXChar` selection based on specified columns and return an `IsFemale` object containing the subsetted data.
# Arguments
* `isXchar_selection`: An `IsXChar` object containing a data representation which
presumably includes values (`val`) and chromosome identifiers (`chr`).
* `subset_selection`: This argument can either be a vector of strings specifying
the chromosomes to retain, or an `InvertedIndex` of a vector of strings
specifying the chromosomes to exclude.
# Returns
* A new `IsXChar` object constructed with the names of the subsetted dataframe
as chromosome identifiers and the first row of the subsetted dataframe as values.
"""
function subset_isXchar(

Check warning on line 229 in src/utils/wrangling_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/wrangling_utils.jl#L229

Added line #L229 was not covered by tests
isXchar_selection::IsXChar,
subset_selection::Union{Vector{String}, InvertedIndex{Vector{String}}}
Expand All @@ -206,7 +242,7 @@ function subset_isXchar(
# selection
select!(df_isxchar, subset_selection)

Check warning on line 243 in src/utils/wrangling_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/wrangling_utils.jl#L243

Added line #L243 was not covered by tests

return IsFemale(
return IsXChar(

Check warning on line 245 in src/utils/wrangling_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/wrangling_utils.jl#L245

Added line #L245 was not covered by tests
names(df_isxchar),
Vector(df_isxchar[1, :])
)
Expand Down Expand Up @@ -234,6 +270,7 @@ function subset_isfemale(
)
end


function subset_covar(

Check warning on line 274 in src/utils/wrangling_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils/wrangling_utils.jl#L274

Added line #L274 was not covered by tests
covar_selection::Covar,
subset_selection::Union{Vector{String}, InvertedIndex{Vector{String}}}
Expand All @@ -257,8 +294,6 @@ function subset_covar(
end




"""
select_sample(geno_selection::Geno, markers_selection:: Union{Vector{String}, InvertedIndex{Vector{String}}}) -> Geno
Expand Down

0 comments on commit 121276b

Please sign in to comment.