I am currently coding program that is 'doing' and plotting phase analysis of DNA sample and something is wrong with it: Output plot HERE! Image on the right side is from MATLAB and is example of how it SHOULD look like. Image on the left is output from my program. As you can see the blue graph looks right but it is under different angle. I've checked the code and it is basicaly same as it is in the MATLAB version of my program. I'll put it here anyway maybe there is a mistake I don't know about. But if it isn't, is there a way of 'turning/lowering' that graph to the right position?
Python code here:
def listIni(size, const=0):
return [const] * size
seq = SeqIO.read("C:/ec.fasta", "fasta")
seqString = seq.format("fasta")
seq = seqString[72:]
seqLen = len(seq)
phase = listIni(seqLen)
A = complex(1, 1)
T = complex(1, -1)
C = complex(-1, -1)
G = complex(-1, 1)
RNL = range(0, seqLen)
ntLoc = np.asarray(RNL)
for i in RNL:
if seq[i] == "A":
phase[i] = np.angle(A)
elif seq[i] == "T":
phase[i] = np.angle(T)
elif seq[i] == "C":
phase[i] = np.angle(C)
else:
phase[i] = np.angle(G)
arrPh = np.asarray(phase)
unwrapedPh = np.unwrap(arrPh)
cumulatedPh = np.cumsum(arrPh)
plt.plot(ntLoc, unwrapedPh, label='uPhase', color='red')
plt.plot(ntLoc, cumulatedPh, label='cPhase', color='blue')
plt.xlabel("Relative nt location")
plt.ylabel("Angle")
plt.show()
I just figured it out. Instead of using 'manual sequence loading' as I did in this part of code:
seq = SeqIO.read("C:/ec.fasta", "fasta")
seqString = seq.format("fasta")
seq = seqString[72:]
seqLen = len(seq)
I just used built-in 'function' in Biopython like this:
record = SeqIO.read("C:/ec.fasta", "fasta")
sequence = record.seq
And everything worked as it should. Why is it like that is still mystery. Anyway thanks for another idea and responding alexblae!