Entering edit mode
4.1 years ago
kbaitsi
•
0
I have written the following code:
library(TraMineR)
sts.data <- c(
"TTATAG",
"AGATAT",
"AGATAG",
"ATATCT",
"AGATAG",
"AGATAG",
"AGATAG",
"TGATAA",
"AGATAA",
"AGATAA",
"CGATAG",
"AGAGTT",
"TGATAA",
"TGATAA",
"AGATGG",
"AGATAG",
"AGATTG",
"AGATAA",
"TGATAA",
"AGATAA",
"AGATAG",
"TGATAG",
"TGATCA",
"TTATCA",
"AGATGG",
"TGATAT",
"AGATAG",
"TGATAA",
"GGATAC",
"AGATAA",
"CGATAA",
"TGATAG",
"AGATAA",
"TGATTA",
"AGATAA",
"AGATAG",
"TGATAT",
"AGATAA",
"TCAGAG",
"AAGTAG",
"AGATTA",
"TGATAG",
"TGATAG",
"AGATAC",
"TGATTG",
"AGATTA",
"AGAATA",
"AGATAA",
"AGATTA",
"AGCTTC"
)
seq1 <- seqdef(seqdecomp(sts.data,sep=''))
seqstatd(seq1)
d <-c(A, C, G, T)
pwm<-matrix(data = d, nrow = 4, ncol = 6)
pwm
bg<- c(0.25, 0.25, 0.25, 0.25)
makepssm <-pwm/bg
makepssm <- makepssm+0.01
pssm <- log2(makepssm)
pssm
calscore<-function(seq,pssm){
score <- 0
for (j in 1:length(pssm[1,])){
score<-score+pssm[seq[j],j]}
return(score)
}
calscore("TTTTTT",pssm)
and when I try to run it it produces the "Error in pssm[seq[j], j] : no 'dimnames' attribute for array"
How can I solve this?
Yesterday it worked multiple times. Could this be a problem of Rstudio?
Are
A
,C
,G
,T
variables or characters :If they are variables, they are not in your script.
If they are characters, you cannot divide characters matrix by float values here :
The
I tried a different approach
but now the error is Error in pssm[seq[j], j] : subscript out of bounds.
You cannot access
A
,C
,G
,T
as you doseqstatd(seq1)
outputs a list of element, you need to grab the "State frequencies" informationsTry to run only these lines :
You will see that
t1
is empty becauseA
cannot be foundI tried that but t1 gives
so does t2 etc. For some reason the code worked fine yesterday even though I received a warning that A cannot be found and today I don't receive this warning but the code doesn't work... Oh temporas, oh mores...