Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
IMP-dev
IMP
Commits
3fa64749
Commit
3fa64749
authored
9 years ago
by
Shaman Narayanasamy
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in R plotting script
parent
ec3b4852
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
src/IMP_visualize_MGMT.R
+27
-4
27 additions, 4 deletions
src/IMP_visualize_MGMT.R
with
27 additions
and
4 deletions
src/IMP_visualize_MGMT.R
+
27
−
4
View file @
3fa64749
...
...
@@ -159,9 +159,23 @@ annot <- readGff3(annot_file, isRightOpen = FALSE)
# extract only interesting information
print
(
"Processing gff3 annotation file"
)
annot.1
<-
as.data.frame
(
cbind
(
as.character
(
annot
@
annotation
$
seq_name
),
annot
@
.Data
,
str_split_fixed
(
str_split_fixed
(
getGffAttribute
(
annot
,
"inference"
),
","
,
2
)[,
2
],
":"
,
3
)[,
2
]))
annot.1
<-
as.data.frame
(
cbind
(
as.character
(
annot
@
annotation
$
seq_name
),
annot
@
.Data
,
str_split_fixed
(
str_split_fixed
(
getGffAttribute
(
annot
,
"inference"
),
","
,
2
)[,
2
],
":"
,
3
)[,
2
]
)
)
colnames
(
annot.1
)
<-
c
(
"contig"
,
"start"
,
"end"
,
"database"
)
# Remove rows with no start and stop positions
annot.1
<-
annot.1
[
-
is.na
(
annot.1
$
start
),]
annot.1
<-
annot.1
[
-
is.na
(
annot.1
$
end
),]
# Replace non-annotated gens with NA
annot.1
$
database
[
annot.1
$
database
==
""
]
=
NA
annot.1
[,
2
:
3
]
<-
sapply
(
annot.1
[
2
:
3
],
as.character
)
...
...
@@ -172,6 +186,7 @@ print("Calculating no. of genes per contig")
annot.2
<-
as.data.frame
(
table
(
annot.1
$
contig
))
colnames
(
annot.2
)[
1
:
ncol
(
annot.2
)]
<-
c
(
"contig"
,
"no_of_genes"
)
save.image
()
# calculate gene lengths
print
(
"Calculating length of genes from gff3 file"
)
annot.1
<-
as.data.frame
(
cbind
(
annot.1
,
annot.1
$
end
-
annot.1
$
start
+
1
))
...
...
@@ -179,8 +194,16 @@ colnames(annot.1)[ncol(annot.1)] <- "gene_length"
# aggregate table and calculate total gene lengths within contig
print
(
"Calculating coding density of contigs"
)
annot.2
<-
cbind
(
annot.2
,
aggregate
(
gene_length
~
contig
,
data
=
annot.1
,
FUN
=
sum
)[,
2
])
colnames
(
annot.2
)[
ncol
(
annot.2
)]
<-
"total_gene_length"
# Create temporary table
total_gene_length
<-
aggregate
(
gene_length
~
contig
,
data
=
annot.1
,
FUN
=
sum
)
colnames
(
total_gene_length
)[
ncol
(
total_gene_length
)]
<-
"total_gene_length"
annot.2
<-
merge
(
annot.2
,
total_gene_length
,
by
=
"contig"
,
all.y
=
FALSE
)
# remove temporary table
rm
(
total_gene_length
)
# create annotation table
print
(
"Creating annotation table"
)
...
...
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