|
1 | | -.chipMeanCounts_multi=function(priorObject,OutfileLoc="./",Outfile){ |
| 1 | +.chipMeanCounts_multi = function(priorObject, OutfileLoc="./", Outfile){ |
2 | 2 |
|
3 | 3 | setwd(OutfileLoc) |
4 | | - ChipSamFile=NULL |
| 4 | + ChipSamFile <- NULL |
5 | 5 | for(i in 1:length(priorObject[['chipSAM']])){ |
6 | | - temp=strsplit(as.character(priorObject[['chipSAM']][i]),'/')[[1]] |
7 | | - ChipSamFile=c(ChipSamFile,temp[length(temp)]) |
| 6 | + temp <- strsplit(as.character(priorObject[['chipSAM']][i]), '/')[[1]] |
| 7 | + ChipSamFile <- c(ChipSamFile, temp[length(temp)]) |
8 | 8 | } |
9 | 9 | #if no uni-reads from sam have been extracted: |
10 | 10 | if(length(priorObject[['chipUni']]) == 0){ |
11 | 11 | for(i in 1:length(ChipSamFile)){ |
12 | | - ChipUniFile=paste(ChipSamFile[i],'.uni.bed',sep='') |
13 | | - priorObject[['chipUni']]=c(priorObject[['chipUni']],paste(OutfileLoc,'/',ChipUniFile,sep='')) |
| 12 | + ChipUniFile <- paste(ChipSamFile[i], '.uni.bed', sep='') |
| 13 | + priorObject[['chipUni']] <- c(priorObject[['chipUni']], paste(OutfileLoc, '/', ChipUniFile, sep='')) |
14 | 14 | # Convert SAM to uni-reads BED format |
15 | | - script='find_uni_bed.pl' |
16 | | - Fn.Path <- system.file( file.path("Perl",script), package="permseq") |
17 | | - CMD<-paste('perl ',Fn.Path,' ', priorObject[['chipSAM']][[i]],' ', OutfileLoc,'/',ChipUniFile,sep='') |
18 | | - system(CMD,intern=TRUE) |
| 15 | + script <- 'find_uni_bed.pl' |
| 16 | + Fn.Path <- system.file(file.path("Perl", script), package="permseq") |
| 17 | + CMD <- paste('perl ', Fn.Path, ' ', priorObject[['chipSAM']][[i]], ' ', OutfileLoc, '/', ChipUniFile, sep='') |
| 18 | + system(CMD, intern=TRUE) |
19 | 19 | } |
20 | 20 | } |
21 | 21 |
|
22 | 22 | for(i in 1:length(ChipSamFile)){ |
23 | 23 | # Count number of reads aligned to each nucleotide |
24 | | - script='count_tags_at_each_nucleotide.pl' |
25 | | - Fn.Path <- system.file( file.path("Perl",script), package="permseq") |
26 | | - ChipUniFile=priorObject[['chipUni']][i] |
27 | | - ChipUniFileN=strsplit(ChipUniFile,'/')[[1]] |
28 | | - ChipUniFileN=ChipUniFileN[length(ChipUniFileN)] |
29 | | - ChipUniCountFile=paste(OutfileLoc,'/',ChipUniFileN,'_count.txt_temp',sep='') |
30 | | - CMD<-paste('perl ',Fn.Path,' ', ChipUniFile,' ',ChipUniCountFile,sep='') |
31 | | - system(CMD,intern=TRUE) |
| 24 | + script <- 'count_tags_at_each_nucleotide.pl' |
| 25 | + Fn.Path <- system.file( file.path("Perl", script), package="permseq") |
| 26 | + ChipUniFile <- priorObject[['chipUni']][i] |
| 27 | + ChipUniFileN <- strsplit(ChipUniFile, '/')[[1]] |
| 28 | + ChipUniFileN <- ChipUniFileN[length(ChipUniFileN)] |
| 29 | + ChipUniCountFile <- paste(OutfileLoc, '/', ChipUniFileN, '_count.txt_temp', sep='') |
| 30 | + CMD <- paste('perl ', Fn.Path, ' ', ChipUniFile, ' ', ChipUniCountFile, sep='') |
| 31 | + system(CMD, intern=TRUE) |
32 | 32 | #split countfiles |
33 | 33 | setwd(OutfileLoc) |
34 | | - outfileLoc=fileDir="./" |
35 | | - file=strsplit(ChipUniCountFile,'/')[[1]] |
36 | | - file=file[length(file)] |
37 | | - system( paste("awk -F \"\\t\" \'{close(f);f=$1}{print > \"",dirname(outfileLoc),"/",basename(outfileLoc), paste("/","/\"f\"",'_',file,"\"}\' ",sep=''),fileDir,file,sep="")) |
| 34 | + outfileLoc <- fileDir <- "./" |
| 35 | + file <- strsplit(ChipUniCountFile, '/')[[1]] |
| 36 | + file <- file[length(file)] |
| 37 | + system( paste("awk -F \"\\t\" \'{close(f);f=$1}{print > \"", dirname(outfileLoc), "/", basename(outfileLoc), paste("/", "/\"f\"", '_', file, "\"}\' ", sep=''), fileDir, file, sep="")) |
38 | 38 |
|
39 | 39 | # Calculate average of ChIP read counts for each group defined by "posLoc_bychr" |
40 | | - script='mean_chip_multidata.pl' |
41 | | - Fn.Path <- system.file( file.path("Perl",script), package="permseq") |
42 | | - chrlist=names(priorObject[['posLoc_bychr']]) |
| 40 | + script <- 'mean_chip_multidata.pl' |
| 41 | + Fn.Path <- system.file(file.path("Perl", script), package="permseq") |
| 42 | + chrlist <- names(priorObject[['posLoc_bychr']]) |
43 | 43 | for(chr in chrlist){ |
44 | | - system(paste('rm -rf ',outfileLoc,'/',chr,'_',Outfile[i],sep='')) |
45 | | - CMD<-paste('perl ',Fn.Path,' ', chr,'_',file,' ',priorObject[['posLoc_bychr']][[chr]],' ',paste(outfileLoc,'/',chr,'_',Outfile[i],sep=''),' ',priorObject[['dataNum']],sep='') |
46 | | - system(CMD,intern=TRUE) |
| 44 | + system(paste('rm -rf ', outfileLoc, '/', chr, '_', Outfile[i], sep='')) |
| 45 | + CMD <- paste('perl ', Fn.Path,' ', chr, '_', file, ' ', priorObject[['posLoc_bychr']][[chr]], ' ', paste(outfileLoc, '/', chr, '_', Outfile[i], sep=''), ' ', priorObject[['dataNum']], sep='') |
| 46 | + system(CMD, intern=TRUE) |
47 | 47 | } |
48 | 48 | } |
49 | 49 | return(priorObject) |
|
0 commit comments