-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path数据整理
38 lines (29 loc) · 1.11 KB
/
数据整理
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
library(dplyr)
# 多条件语句替换
rt3<-rt2 %>%mutate(fustat=case_when(fustat == "Alive" ~ 0,
fustat == "Dead" ~ 1))
rt4<-rt3 %>% mutate(M = replace(M, M =="", NA),N = replace(N, N =="", NA),
T = replace(T, T =="", NA),
cacer_status = replace(cacer_status, cacer_status =="", NA))
# 批量改变字符型至factor因子
for (i in c(5,7:10)){
rt3[,i] <- as.factor(rt3[,i])
}
Lnct<-Lnc[,-c(2:52)]
Lnct<- na.omit(Lnct)#删除有空值的行
Lnct%>%filter(rowSums(Lnct[,2:490])>1)->rr
data3 <-aggregate( .~id,data=rr, max)
rownames(data3)<-data3$id
data3$id<-NULL
write.table(data3,'lncRNA.csv',quote=F, sep = "\t")
cou<-read.table('mutCount.txt',sep = '\t',header = T,check.names = F)
quantile(cou$Count)
cou1<-cou%>%filter(Count<=26|Count>=44)
arrange(cou1,Count)->cou1
sum(cou1$Count<=26)
sum(cou1$Count>=44)
gid<-substr(cou1$id,1,16)
data3[,which(substr(colnames(data3),1,16)%in%gid[1:133])]->GS
data3[,which(substr(colnames(data3),1,16)%in%gid[134:262])]->GU
lncRNA.mutGroup<-cbind(GS,GU)
write.csv(lncRNA.mutGroup,'lncRNA.mutGroup.csv',quote=F)