I'm not going to claim that Japanese don't intentionally pretend to sit next to a foreigner and at the last moment, pull away because I'm sure it happens. In my experience what seems more likely is that a Japanese person will go to sit by me and suddenly change their mind if I make eye contact with them. I think most Japanese people, especially women are cowards.
I also notice that when I'm getting off at the same stop as a Japanese woman that exhibits this sort of odd behavior, they will almost always try to move away from you and make sure to exit the train from a different door.
I hear the "cough" and the "atsui" all the time. I often will mimic them. A racist old fart coughs, I cough right after and make eye contact. If some old hag says atsui sitting right under an AC fan on the train, I say atsui and exaggerate by pulling on my collar.
You are catching on a bit more. I will often reflect/do back the behavior that Japanese give me, to show them what's it like or that their micro-aggressive behavior has been noticed. By identifying micro-aggressive behavior, it shows me those Japanese to avoid, be wary, or not to trust in a relationship, business, business establishment, or work context.
As for the Japanese "sit next to a foreigner game", I see it as a combination of both. Sometimes intentional/bias/racist, and sometimes cowardice/fear/paranoia. I've played this "game" with Japanese too, as an experiment. Among the funniest reactions was a Japanese guy that followed me, after I didn't sit down and moved away, then he sits next me on the next train car. I just started laughing, and he smiled. It's interesting that a lot of Japanese feel just as freaked out and insulted when foreigners play the same games on them.
I think empathy (or lack of it) is another issue in Japan, and if you Google it, you will find a lot of discussion on it. Just like there is a difference between how Japanese culture process "guilt" and "shame", there is also a culture difference from Western culture in how Japanese process "empathy" and "compassion". That is, the Japanese feel compassion, but lack empathy, particularly for anybody outside their group or family. This is partially a source of micro-aggressive and bullying type of behavior.
I think the cowardice comes from a lot of social anxiety disorders, insecurities, fear, and paranoia about anything different and outside their small bubble. It's sad that too many people go through life that way, but you have to accept they won't change, until they can realize what they are doing and develop the courage to change.
TokyoJoeblow, as you begin to notice these behaviors more, try to be the "better man" about it. Realize that various people are doing things unthinkingly or subconsciously, like sleep walking through life. Show some compassion and understanding towards them.