-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
113 lines (113 loc) · 3.58 KB
/
.Rhistory
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
plot_beta(Gibbs_model_example,prob=0.01)
library(metatopics)
dim(meta_counts)
colnames(meta_counts)[1:10]
head(genus_2_phylum)
rownames(meta_counts)
table(lls)
lls[which(lls=="OLP_BW")]="OLP_non-erosive"
lls[which(lls=="OLP_CXML")]="OLP_erosive"
meta_abundance <- micro.abundance(meta_counts,1)
genus_2_phylum=genus_2_phylum[colnames(meta_abundance),]
abundance.plot(meta_abundance,classification = genus_2_phylum$phylum,col=genus_2_phylum$colour)
```
library(BiotypeR)
data.denoized=noise.removal(t(meta_counts), percent=0.01)
samples=colnames(data.denoized)
bacteria=rownames(data.denoized)
data.final=meta_counts[samples,bacteria]
dim(data.final)
library(slam)
library(topicmodels)
dtm=as.simple_triplet_matrix(data.final)
seed_num=2014
fold_num=5
kv_num = c(2:30)
control = list(seed = seed_num, burnin = 1000,thin = 100, iter = 1000)
sp=smp(cross=fold_num,n=nrow(dtm),seed=seed_num)
#not run: system.time((ctmK=selectK(dtm=dtm,kv=kv_num,SEED=seed_num,cross=fold_num,sp=sp,method='Gibbs',control=control)))
Gibbs_model_example = LDA(dtm, k = 10, method = "Gibbs",
control = list(seed = seed_num, burnin = 1000,thin = 100, iter = 1000))
dim(Gibbs_model_example@beta)
apply(exp(Gibbs_model_example@beta),1,sum)
library(ggplot2)
plot_beta(Gibbs_model_example,prob=0.01)
plot_network(Gibbs_model_example,prob=0.05)
pdf(file='plot_network.pdf')
plot_network(Gibbs_model_example,prob=0.05)
dev.off()
pdf(file='plot_gamma.pdf')
plot_gamma(Gibbs_model_example,lls,prob=0.05)
dev.off()
pdf(file='plot_gamma.pdf',width=8,height=6)
plot_gamma(Gibbs_model_example,lls,prob=0.05)
dev.off()
pdf(file='plot_gamma.pdf',width=8,height=5)
plot_gamma(Gibbs_model_example,lls,prob=0.05)
dev.off()
pdf(file='plot_beta.pdf',width=6,height=6)
plot_beta(Gibbs_model_example,prob=0.01)
dev.off()
pdf(file='plot_beta.pdf',width=5,height=5)
plot_beta(Gibbs_model_example,prob=0.01)
dev.off()
library(LDAvis)
data(TwentyNewsgroups, package="LDAvis")
json <- with(TwentyNewsgroups,
createJSON(phi, theta, doc.length, vocab, term.frequency))
serVis(json) # press ESC or Ctrl-C to kill
help(servis)
help(serVis)
help(creatJOSN)
help(creatJSON)
help(createJSON)
dim(TwentyNewsgroups$phi)
TwentyNewsgroups[1:5,1:5]
TwentyNewsgroups$phi[1:5,1:5]
apply(TwentyNewsgroups$phi,1,sum)
a = Gibbs_model_example@beta
dim(a)
a[1:5,1:5]
plot_beta
dim(Gibbs_model_example@gamma)
dim(TwentyNewsgroups$theta)
Gibbs_model_example@gamma
TwentyNewsgroups$doc.length
dim(TwentyNewsgroups$doc.length)
length(TwentyNewsgroups$doc.length)
length(TwentyNewsgroups$vocab)
length(TwentyNewsgroups$term.frequency)
plot_beta
Gibbs_model_example@terms
Gibbs_model_example@documents
TwentyNewsgroups$term.frequency[1:10]
class(Gibbs_model_example@z)
length(Gibbs_model_example@z)
(Gibbs_model_example@z)[1:10]
Gibbs_model_example@wordassignments[1:10,1:10]
dim(data.final)
head(data.final)
data.final[1:5,1:5]
rownames(data.final)
Gibbs_model_example@documents
sum(rownames(data.final) == Gibbs_model_example@documents)
sum(rownames(data.final) != Gibbs_model_example@documents)
sum(colnames(data.final) != Gibbs_model_example@terms)
json <- createJSON(phi = exp(Gibbs_model_example@beta),
theta = Gibbs_model_example@gamma,
doc.length = apply(data.final,1,sum),
vocab = Gibbs_model_example@terms,
term.frequency = apply(data.final,2,sum))
serVis(json)
serVis(json, out.dir=Testing, open.browser = FALSE
serVis(json, out.dir=olp_html,open.browser = FALSE)
serVis(json, out.dir='olp_html',open.browser = FALSE)
library(metatopics)
library(Metatopics)
library(MetaTopics)
library(MetaTopics)
dim(meta_counts)
library(BiotypeR)
data.denoized=noise.removal(t(meta_counts), percent=0.01)
library(clusterSim)
??colorview