Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcodonusage
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Blaise LI
libcodonusage
Commits
64894825
Commit
64894825
authored
3 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Option to exclude columns for PCA.
parent
6530db56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libcodonusage/libcodonusage.py
+8
-1
8 additions, 1 deletion
libcodonusage/libcodonusage.py
with
8 additions
and
1 deletion
libcodonusage/libcodonusage.py
+
8
−
1
View file @
64894825
...
@@ -667,7 +667,9 @@ methionine (M) and tryptophan (W).
...
@@ -667,7 +667,9 @@ methionine (M) and tryptophan (W).
all_nan_cols
)
all_nan_cols
)
def
codon_usage_pca
(
usage_data
,
figs_dir
=
None
,
hue
=
"
chrom
"
):
def
codon_usage_pca
(
usage_data
,
figs_dir
=
None
,
hue
=
"
chrom
"
,
exclude_cols
=
None
):
"""
"""
Perform Principal Component Analysis on *usage_data*.
Perform Principal Component Analysis on *usage_data*.
...
@@ -689,10 +691,15 @@ def codon_usage_pca(usage_data, figs_dir=None, hue="chrom"):
...
@@ -689,10 +691,15 @@ def codon_usage_pca(usage_data, figs_dir=None, hue="chrom"):
in the first four principal components (0 vs. 1 and 2 vs. 3)
in the first four principal components (0 vs. 1 and 2 vs. 3)
as well as graphics representing the influence of each data column
as well as graphics representing the influence of each data column
on the first four principal components.
on the first four principal components.
If *exclude_cols* is not None, the columns with the names contained
in the iterable *exclude_cols* will not be included in the PCA analysis.
"""
"""
if
figs_dir
is
not
None
:
if
figs_dir
is
not
None
:
figs_dir
=
Path
(
figs_dir
)
figs_dir
=
Path
(
figs_dir
)
figs_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
figs_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
if
exclude_cols
is
not
None
:
usage_data
=
usage_data
.
drop
(
columns
=
exclude_cols
)
pca
=
PCA
().
fit
(
usage_data
)
pca
=
PCA
().
fit
(
usage_data
)
transformed_data
=
pd
.
DataFrame
(
transformed_data
=
pd
.
DataFrame
(
pca
.
transform
(
usage_data
),
pca
.
transform
(
usage_data
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment