Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
N
ngs_tools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
bioinfo
ngs_tools
Commits
797c616b
Commit
797c616b
authored
Nov 06, 2019
by
domingue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed file added by mistake
parent
e162a949
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
98 deletions
+0
-98
ms_workflow/03-filtering_aneuploid.R
ms_workflow/03-filtering_aneuploid.R
+0
-98
No files found.
ms_workflow/03-filtering_aneuploid.R
deleted
100644 → 0
View file @
e162a949
# ==========================================================================
# Setup
# ==========================================================================
library
(
"corescf"
)
library
(
"data.table"
)
library
(
"dplyr"
)
library
(
"ComplexHeatmap"
)
library
(
"stringr"
)
library
(
"ggplot2"
)
library
(
"ggridges"
)
library
(
"heatmaply"
)
library
(
"RColorBrewer"
)
# ==========================================================================
# Data
# ==========================================================================
dir.create
(
results_dir
,
showWarnings
=
FALSE
,
recursive
=
TRUE
)
data_dir
<-
paste0
(
Sys.getenv
(
"PRJ_DATA"
),
"/data"
)
results_dir
<-
paste0
(
Sys.getenv
(
"PRJ_DATA"
),
"/aneuploid_cells"
)
dloup_file
<-
paste0
(
data_dir
,
"/all_C13_mother-group_876-region_chr1_1-5120000_chrY_56320001-57227415-heatmap_copy_number.csv"
)
dloup
<-
fread
(
dloup_file
)
%>%
mutate
(
node_id
=
as.character
(
node_id
))
# colnames(dloup)[1:10]
#
# metadata
# --------------------------------------------------------------------------
metadata
<-
dloup
%>%
select
(
node_id
,
barcodes
,
num_cells
,
num_noisy
)
cells
<-
dloup
%>%
select
(
-
c
(
"barcodes"
,
"num_cells"
,
"num_noisy"
))
# ==========================================================================
# Filtering
# ==========================================================================
cells_long
<-
cells
%>%
gather
(
"segment"
,
"copy_number"
,
-
node_id
)
%>%
mutate
(
chromosome
=
gsub
(
"(.*):.*"
,
"\\1"
,
segment
))
%>%
filter
(
chromosome
!=
"chrY"
)
# head(cells_long)
#
# mean ploidy
# --------------------------------------------------------------------------
aneuploid_cells
<-
cells_long
%>%
group_by
(
node_id
,
chromosome
)
%>%
arrange
(
node_id
,
chromosome
)
%>%
mutate
(
is_segment_missing
=
ifelse
(
copy_number
<
0.8
,
"yes"
,
"no"
)
)
%>%
summarize
(
mean_ploidy
=
mean
(
copy_number
,
na.rm
=
TRUE
),
Frac_intact_chromosome
=
sum
(
is_segment_missing
==
"no"
,
na.rm
=
TRUE
)
/
n
(),
is_chromosome_missing
=
ifelse
(
Frac_intact_chromosome
<
0.1
,
"yes"
,
"no"
)
)
%>%
filter
(
is_chromosome_missing
==
"yes"
)
ungroup
()
%>%
group_by
(
node_id
)
%>%
mutate
(
mean_ploidy
=
round
(
mean_ploidy
,
2
),
is_abnormal
=
ifelse
(
mean_ploidy
<=
1.75
|
mean_ploidy
>=
4
,
"yes"
,
"no"
),
N_Complete_Karyotype
=
sum
(
is_abnormal
==
"no"
),
Frac_Complete_Karyotype
=
sum
(
is_abnormal
==
"no"
)
/
n
()
)
%>%
filter
(
is_abnormal
==
"yes"
)
aneuploid_id
<-
unique
(
aneuploid_cells
$
node_id
)
#
# Visualization
# --------------------------------------------------------------------------
mat
<-
cells
%>%
as.data.frame
()
%>%
column2rownames
(
"node_id"
)
%>%
as.matrix
()
mat_filt
<-
mat
[
aneuploid_id
,
]
Heatmap
(
mat_filt
,
cluster_columns
=
FALSE
,
# col = binary_cols,
show_column_names
=
FALSE
# column_split = noisy_lab,
# row_split = noisy_lab
)
# ==========================================================================
# Reproducibility
# ==========================================================================
session
::
save.session
(
".03-filtering_aneuploid.dat"
)
devtools
::
session_info
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment