Skip to content

Commit 5be2834

Browse files
authored
Merge pull request #19 from sdentro/dev
Merging v2.2.2
2 parents 2418da6 + 9017bda commit 5be2834

File tree

6 files changed

+76
-6
lines changed

6 files changed

+76
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Maintainer: Stefan Dentro <[email protected]>
33
License: GPL-3
44
Type: Package
55
Title: Battenberg subclonal copy number caller
6-
Version: 2.2.1
6+
Version: 2.2.2
77
Authors@R: c(person("David", "Wedge", role=c("aut"), email="[email protected]"),
88
person("Peter", "Van Loo", role=c("aut")),
99
person("Stefan","Dentro", email="[email protected]", role=c("aut", "cre")),

R/fitcopynumber.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ callSubclones = function(sample.name, baf.segmented.file, logr.file, rho.psi.fil
273273
#if no points to plot, skip
274274
if (length(pos)==0) { next }
275275

276-
if (!is.null(sv_breakpoints_file)) {
276+
if (!is.null(sv_breakpoints_file) & !sv_breakpoints_file=="NA") {
277277
svs_pos = svs[svs$chromosome==chr,]$position / 1000000
278278
} else {
279279
svs_pos = NULL
@@ -315,7 +315,7 @@ callSubclones = function(sample.name, baf.segmented.file, logr.file, rho.psi.fil
315315
is_subclonal_min[is.na(is_subclonal_min)] = F
316316
segment_states_min = subclones$nMin1_A * ifelse(is_subclonal_min, subclones$frac1_A, 1) + ifelse(is_subclonal_min, subclones$nMin2_A, 0) * ifelse(is_subclonal_min, subclones$frac2_A, 0)
317317
segment_states_maj = subclones$nMaj1_A * ifelse(is_subclonal_maj, subclones$frac1_A, 1) + ifelse(is_subclonal_maj, subclones$nMaj2_A, 0) * ifelse(is_subclonal_maj, subclones$frac2_A, 0)
318-
ploidy = sum((segment_states_min+segment_states_maj) * seg_length) / sum(seg_length)
318+
ploidy = sum((segment_states_min+segment_states_maj) * seg_length, na.rm=T) / sum(seg_length, na.rm=T)
319319

320320
# Plot genome wide figures
321321
plot.gw.subclonal.cn(subclones=subclones, BAFvals=BAFvals, rho=rho, ploidy=ploidy, goodness=goodness, output.gw.figures.prefix=output.gw.figures.prefix, chr.names=chr_names)

R/prepare_wgs.R

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,23 @@ gc.correct.wgs = function(Tumour_LogR_file, outfile, correlations_outfile, gc_co
288288

289289
GCcorrected = Tumor_LogR[!flag_NA,]
290290
GCcorrected[,3] = model$residuals
291-
291+
rm(Tumor_LogR)
292+
292293
corr = data.frame(windowsize=names(corr), correlation=corr)
293-
write.table(corr, file=correlations_outfile, sep="\t", quote=F, row.names=F)
294+
write.table(corr, file=gsub(".txt", "_beforeCorrection.txt", correlations_outfile), sep="\t", quote=F, row.names=F)
294295
write.table(GCcorrected, file=outfile, sep="\t", quote=F, row.names=F)
296+
297+
# Recalculate the correlations to see how much there is left
298+
snps_gccorrected = paste(GCcorrected[,1], GCcorrected[,2], sep="_")
299+
snps_gcdata = paste(GC_data[,1], GC_data[,2], sep="_")
300+
snps_intersect = intersect(snps_gccorrected, snps_gcdata)
301+
GCcorrected = GCcorrected[snps_gccorrected %in% snps_intersect, ]
302+
GC_data = GC_data[snps_gcdata %in% snps_intersect, ]
303+
304+
flag_nona = is.finite(GCcorrected[,3])
305+
corr = cor(GC_data[flag_nona, 3:ncol(GC_data)], GCcorrected[flag_nona,3], use="complete.obs")
306+
length = nrow(GCcorrected)
307+
corr = apply(corr, 1, function(x) sum(abs(x*length))/sum(length))
308+
corr = data.frame(windowsize=names(corr), correlation=corr)
309+
write.table(corr, file=gsub(".txt", "_afterCorrection.txt", correlations_outfile), sep="\t", quote=F, row.names=F)
295310
}

man/callSubclones.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
\usage{
77
callSubclones(sample.name, baf.segmented.file, logr.file, rho.psi.file,
88
output.file, output.figures.prefix, output.gw.figures.prefix, chr_names,
9-
masking_output_file, max_allowed_state = 100, sv_breakpoints_file = NULL,
9+
masking_output_file, max_allowed_state = 250, sv_breakpoints_file = NULL,
1010
gamma = 1, segmentation.gamma = NA, siglevel = 0.05, maxdist = 0.01,
1111
noperms = 1000, seed = as.integer(Sys.time()))
1212
}

man/determine_copynumber.Rd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/fitcopynumber.R
3+
\name{determine_copynumber}
4+
\alias{determine_copynumber}
5+
\title{Given all the determined values make a copy number call for each segment}
6+
\usage{
7+
determine_copynumber(BAFvals, LogRvals, rho, psi, gamma, ctrans, ctrans.logR,
8+
maxdist, siglevel, noperms)
9+
}
10+
\arguments{
11+
\item{BAFvals}{BAFsegmented data.frame with 5 columns}
12+
13+
\item{LogRvals}{Raw logR values in data.frame with 3 columns}
14+
15+
\item{rho}{Optimal rho value, the choosen cellularity}
16+
17+
\item{psi}{Optimal psi value, the choosen ploidy}
18+
19+
\item{gamma}{Platform gamma parameter}
20+
}
21+
\value{
22+
A data.frame with copy number determined for each segment
23+
}
24+
\description{
25+
Given all the determined values make a copy number call for each segment
26+
}
27+
\author{
28+
dw9
29+
}
30+

man/mask_high_cn_segments.Rd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
% Generated by roxygen2 (4.1.1): do not edit by hand
2+
% Please edit documentation in R/fitcopynumber.R
3+
\name{mask_high_cn_segments}
4+
\alias{mask_high_cn_segments}
5+
\title{Mask segments that have a too high CN state}
6+
\usage{
7+
mask_high_cn_segments(subclones, bafsegmented, max_allowed_state)
8+
}
9+
\arguments{
10+
\item{subclones}{}
11+
12+
\item{bafsegmented}{}
13+
14+
\item{max_allowed_state}{}
15+
}
16+
\value{
17+
A list with the masked subclones, bafsegmented and the number of segments masked and their total genome size
18+
}
19+
\description{
20+
Mask segments that have a too high CN state
21+
}
22+
\author{
23+
sd11
24+
}
25+

0 commit comments

Comments
 (0)