Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PAQR_KAPAC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
zavolan_public
PAQR_KAPAC
Commits
e6d1788d
Commit
e6d1788d
authored
7 years ago
by
BIOPZ-Schmidt Ralf
Browse files
Options
Downloads
Patches
Plain Diff
modified plot-ecdfs.R to be more generic
parent
f625bd61
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PAQR/scripts/plot-ecdfs.R
+8
-53
8 additions, 53 deletions
PAQR/scripts/plot-ecdfs.R
with
8 additions
and
53 deletions
PAQR/scripts/plot-ecdfs.R
+
8
−
53
View file @
e6d1788d
...
...
@@ -81,19 +81,6 @@ iwanthue <- function(n, hmin=0, hmax=360, cmin=0, cmax=180, lmin=0, lmax=100,
hex
(
LAB
(
clus
$
centers
))
}
################################################################################
# define function to infer the patient and the sample type from TCGA barcodes
################################################################################
get_tissue_code
<-
function
(
barcode
){
substring
(
tail
(
strsplit
(
strsplit
(
barcode
,
"_"
)[[
1
]][
2
],
"-"
)[[
1
]],
n
=
1
),
1
,
2
)
}
get_patient_id
<-
function
(
barcode
){
head
(
tail
(
strsplit
(
strsplit
(
barcode
,
"_"
)[[
1
]][
2
],
"-"
)[[
1
]],
n
=
2
),
n
=
1
)
}
################################################################################
################################################################################
...
...
@@ -105,28 +92,13 @@ pdf_out <- opt$pdf
# load input table
lengthPerExon
<-
read.table
(
input
,
head
=
T
,
row.names
=
1
,
check.names
=
FALSE
)
# sort them by patient ids (sample from the same patient are next to each other)
patient_ids
<-
sapply
(
colnames
(
lengthPerExon
),
get_patient_id
)
lengthPerExon
<-
lengthPerExon
[,
order
(
patient_ids
)]
patient_ids
<-
patient_ids
[
order
(
patient_ids
)]
# colnames contains the TCGA-barcodes
# check all cols that are from primary tumor samples
tissue_code
<-
sapply
(
colnames
(
lengthPerExon
),
get_tissue_code
)
################################################################################
# define the set of used colors and the color for each column
################################################################################
# the number of needed colors equals the number of distinct patients
nr_colors
<-
length
(
unique
(
patient_ids
))
# if( nr_colors >= 2) {
# colors <- rainbow(nr_colors)
# } else {
# colors <- rainbow(2)
# }
nr_colors
<-
length
(
colnames
(
lengthPerExon
))
# use johnbaums' code of iwanthue to get distinct colors
colors
<-
iwanthue
(
nr_colors
)
...
...
@@ -135,42 +107,25 @@ colors <- iwanthue(nr_colors)
colors_per_columns
<-
rep
(
"unset"
,
dim
(
lengthPerExon
)[
2
])
# lty_per_columns <- rep(2,dim(lengthPerExon)[2])
# define the color for each column (based on the patient id)
sample_ids
<-
colnames
(
lengthPerExon
)
# define the color for each column (based on the sample id)
tmp_cnt
<-
0
patient
s_visited_already
<-
c
()
sample
s_visited_already
<-
c
()
for
(
n
in
1
:
dim
(
lengthPerExon
)[
2
])
{
if
(
patient_ids
[
n
]
%in%
patients_visited_already
)
{
colors_per_columns
[
n
]
<-
colors
[
tmp_cnt
]
colors_per_columns
[
n
]
<-
colors
[
which
(
patients_visited_already
==
patient_ids
[
n
])
]
if
(
sample_ids
[
n
]
%in%
samples_visited_already
)
{
colors_per_columns
[
n
]
<-
colors
[
which
(
samples_visited_already
==
sample_ids
[
n
])
]
}
else
{
tmp_cnt
<-
tmp_cnt
+
1
colors_per_columns
[
n
]
<-
colors
[
tmp_cnt
]
patient
s_visited_already
[
tmp_cnt
]
<-
patient
_ids
[
n
]
sample
s_visited_already
[
tmp_cnt
]
<-
sample
_ids
[
n
]
}
# if(colors_per_columns[n] != "unset") next
# tmp_cnt <- tmp_cnt + 1
# curr_col_name <- colnames(lengthPerExon)[n]
# curr_type <- tissue_code[n]
# patient <- strsplit(curr_col_name,"-")[[1]][3]
# tmp_pair <- grep( patient, colnames(lengthPerExon) )
# stopifnot(length(tmp_pair) == 2)
# matching_sample_idx <- tmp_pair[tmp_pair != n]
# colors_per_columns[n] <- colors[tmp_cnt]
# colors_per_columns[matching_sample_idx] <- colors[tmp_cnt]
# if(grepl("^01",curr_type)){
# lty_per_columns[ matching_sample_idx ] <- 2
# } else{
# lty_per_columns[n] <- 2
# }
}
if
(
"unset"
%in%
colors_per_columns
)
stop
(
'missing color assingment to some samples'
)
# convert colors to matrix of rgb values
col_matrix
<-
col2rgb
(
colors_per_columns
,
alpha
=
TRUE
)
/
255
# set alpha channel for all "primary tumor" samples to 0.1
col_matrix
[
4
,
grep
(
"01"
,
tissue_code
)]
<-
0.1
################################################################################
# create the CDF for every column and plot it
...
...
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