Question: (Closed) nrow,ncol name,matrix name
0
4.6 years ago by
Turkey
gizemtatar0 wrote:

My input;

seq1="GCATGCU"

seq2="GATTACA"

n=length(s1string) #seq1

m=length(s2string) #seq2

This matrix

D <- matrix(0,nrow=m+1, ncol=n+1)

seq1 and seq2 length = 7 but I must create matrix 8x8:

[,1]  [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    0   -1   -2   -3   -4   -5   -6   -7
[2,]   -1    1    0   -1   -2   -3   -4   -5
[3,]   -2    0    0    1    0   -1   -2   -3
[4,]   -3   -1   -1    0    2    1    0   -1
[5,]   -4   -2   -2   -1    1    1    0   -1
[6,]   -5   -3   -3   -1    0    0    0   -1
[7,]   -6   -4   -2   -2   -1   -1    1    0
[8,]   -7   -5   -3   -1   -2   -2    0    0

I want to define matrix ncol with s1string, nrow= s2string but start colname and rowname [2, ], [,2].  for example, [,2]="G" [,3]="C" [,4]="A" [,5]="T" [,6]="G" [,7]="C" [,8]="T" . I don't want define in this [1,1].  Can you help me for this topic?

sequence • 1.6k views
written 4.6 years ago by gizemtatar0

Hello gizemtatar!

Questions similar to yours can already be found at:

We have closed your question to allow us to keep similar content in the same thread.

If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.

Cheers!

ı try it but programme give error :

Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent

For sure it won't work, because dimnames must have same length as the matrix dimensions, why do you want to assign 7 dimnames to an 8x8 matrix. Your matrix looks like a scoring matrix. So the solution is obvious: define proper dimension names of length 8. So what's in the additional column?

Yes, I know. I create scoring matrix but this matrix Needleman-Wunsch global alignment matrix. And I need this matrix.