-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathreorganize_folder.R
51 lines (40 loc) · 1.35 KB
/
reorganize_folder.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
###
library(jaffelab)
library(filesstrings)
## unpack
system("tar xvf Lieber_Visium_Transfer_1.tar")
system("tar xvf Lieber_Visium_Transfer_2.tar")
## move to common folder
system("mv Lieber_Visium_Transfer_1/ 10X")
system("mv Lieber_Visium_Transfer_2/ 10X")
system("mv Lieber_Visium_Transfer_2/Lieber/ Analysis/")
## make sample-specific folders
path = "/dcs04/lieber/lcolladotor/with10x_LIBD001/HumanPilot/10X"
f = list.files(path, full =TRUE)
names(f) = list.files(path)
fList = split(f, ss(names(f), "_"))
for(i in seq(along=fList)) {
newpath = paste0(path, "/", names(fList)[i])
dir.create(newpath)
file.move(fList[[i]], newpath)
}
## move analysis output
path2 = "/dcs04/lieber/lcolladotor/with10x_LIBD001/HumanPilot/Analysis"
f2 = list.files(path2,full =TRUE,recur=TRUE)
names(f2) = ss(f2, "/", 8)
f2 = f2[grepl("^1", names(f2))]
fList2 = split(f2, names(f2))
for(i in seq(along=fList2)) {
newpath = paste0(path, "/", names(fList)[i])
file.move(fList2[[i]], newpath)
}
### and loupe files
path3 = "/dcs04/lieber/lcolladotor/with10x_LIBD001/HumanPilot/10X/Lieber_websummary_and_loupe"
f3 = list.files(path3,full =TRUE,recur=TRUE)
names(f3) = ss(ss(f3, "/", 9), "\\.")
names(f3) = ss(names(f3), "_")
fList3 = split(f3, names(f3))
for(i in seq(along=fList3)) {
newpath = paste0(path, "/", names(fList3)[i])
file.move(fList3[[i]], newpath,overwrite=TRUE)
}